Skip to content

Instantly share code, notes, and snippets.

@danilowoz
Created April 28, 2019 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danilowoz/c4da3964bd02b64419906b4e8bc7c7aa to your computer and use it in GitHub Desktop.
Save danilowoz/c4da3964bd02b64419906b4e8bc7c7aa to your computer and use it in GitHub Desktop.
Next and prev post
posts.forEach((post, index, arr) => {
post.node.frontmatter.category.forEach(cat => categories.push(cat))
const prev = arr[index - 1]
const next = arr[index + 1]
createPage({
path: post.node.fields.slug,
component: blogLayout,
context: {
slug: post.node.fields.slug,
prev: prev,
next: next,
},
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment