Gatsby: Linking between pages via GraphCMS

Created on 20 Jan 2020  路  2Comments  路  Source: gatsbyjs/gatsby

Summary

Hey team,

I'm currently developing a web application that behaves a lot like a blog, where content is being pulled in from GraphCMS and rendered by a template.

I'd love to leverage the tools that Gatsby includes out of the box, like the <Link /> component, to link to internal pages, but I haven't found a way to do that in the pages created in GraphCMS and generated by Gatsby?

My first thought would be manually typing the html inside of the GraphCMS content page, and ensuring that Link is imported inside of the template, but the html is serialised as string when rendered by my application.

Another thought I've had would be searching through the content when rendering the page and replacing an arbitrary token with the link component. Although this sounds expensive, and error prone if I went ahead and did this myself.

I'm surprised that I haven't found any similar issues, considering that GraphCMS seems to be the defacto CMS to use with Gatsby, and one of Gatsby's many benefits is it's ability to preload internal pages (this goes out of the window if I have top default to an anchor tag.

Relevant information

Environment (if relevant)

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

question or discussion

All 2 comments

Thank you for opening this!

You can use: gatsby-plugin-catch-links

As an example:

image

This internal link in Prismic.io gets converted to a <Link /> here then: https://prismic.lekoarts.de/introducing-the-wall

considering that GraphCMS seems to be the defacto CMS to use with Gatsby

There isn't a defacto CMS with Gatsby as you can use any datasource with Gatsby :)

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Thanks so much, this is exactly what I needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinhorton picture dustinhorton  路  3Comments

hobochild picture hobochild  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

benstr picture benstr  路  3Comments

totsteps picture totsteps  路  3Comments