Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get React Router to handle links to markdown files? #384

Closed
hiddentao opened this issue Aug 10, 2016 · 2 comments
Closed

How do I get React Router to handle links to markdown files? #384

hiddentao opened this issue Aug 10, 2016 · 2 comments

Comments

@hiddentao
Copy link
Contributor

I have a folder structure like:

pages/
  docs/
    index.md
    Middleware/
      index.md

In pages/docs/index.md I have a link to the middleware docs like: `Middleware.

When I run gatsby develop the pages get rendered correctly. But when I click the middleware link above the browser loads the Middleware HTML page afresh instead of doing an in-page navigation (i.e. using React Router).

What am I doing wrong?

@hiddentao
Copy link
Contributor Author

I've tried to figure this out from looking at Gatsby code. From what I can see the files are stored in the bundle.js using against their original paths rather than the URL I use in the link (e.g. ./docs/Middleware/index.md). Perhaps this is a reason why the React Router doesn't handle the URL?

@hiddentao hiddentao changed the title How do I use SPA React routing for links to markdown files? How do I get React Router to handle links to markdown files? Aug 10, 2016
@KyleAMathews
Copy link
Contributor

You want to do something like this line in gatsby-starter-blog https://github.com/gatsbyjs/gatsby-starter-blog/blob/master/pages/index.js#L29

Use the <Link> component from react-router and prefixLink from 'gatsby-helpers' if you are deploying to something like Github pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants