Include Links to Next and Previous Gatsby v1 Blog Posts

InstructorTaylor Bell

Share this video with your friends

Send Tweet

Gatsby’s createPage action allows for additional data to be passed in via context. In this lesson, we will add a processing step to include links between posts, and update our templates to conditionally display them as appropriate.

Scott Spence
~ 7 years ago

Hi, this doesn't quite seem to work for me, I have pretty much the same setup but when I have my most recent post the previous and next point to posts that are not in the same order as what is displayed on the main page.

I've tried looking at the query on ___grapgql but it only returns one post, I'm struggling to debug what exactly is going on.

Marcus
~ 7 years ago

Hey Scott, same here. I'm running into the same issue :(

Scott Spence
~ 7 years ago

Take a look at gatsby-node.js Marcus

https://github.com/tayiorbeii/gatsby-demo-blog-code/issues/2

Marcus
~ 7 years ago

Thanks Scott!

Scott Spence
~ 7 years ago

LMK if that worked for you, worked for me. It did take me a while to figure it out.

Stephen James
~ 7 years ago

Is there something special about pathContext variable name? Just creating an object context is mapped to pathContext in all cases?