Created
April 27, 2020 07:28
-
-
Save rubenRP/035cbf14e303d55188968f77cf070afd to your computer and use it in GitHub Desktop.
This file contains hidden or 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) => { | |
const previous = index === posts.length - 1 ? null : posts[index + 1].node | |
const next = index === 0 ? null : posts[index - 1].node | |
const path = post.node.fileAbsolutePath | |
const regex = "/blog/" | |
if (path.match(regex)) { | |
createPage({ | |
path: `blog${post.node.fields.slug}`, | |
component: blogPost, | |
context: { | |
slug: post.node.fields.slug, | |
previous, | |
next, | |
}, | |
}) | |
} else { | |
createPage({ | |
path: `${post.node.fields.slug}`, | |
component: defaultPage, | |
context: { | |
slug: post.node.fields.slug, | |
}, | |
}) | |
} | |
// return null | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment