Created
April 28, 2019 20:01
-
-
Save danilowoz/c4da3964bd02b64419906b4e8bc7c7aa to your computer and use it in GitHub Desktop.
Next and prev post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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