Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Next and prev post
const BlogPost = ({ data, pageContext }) => {
const { markdownRemark } = data
const { prev, next } = pageContext
return (
<>
...
{prev && (
<Link to={prev.node.fields.slug}>
{"<"} {prev.node.frontmatter.title}
</Link>
)}
{next && (
<Link to={next.node.fields.slug}>
{next.node.frontmatter.title} {">"}
</Link>
)}
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment