Created
April 27, 2020 07:27
-
-
Save rubenRP/e0f23cacb426724676f1e5100905b19e 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
// Create pages and blog posts. | |
const posts = result.data.pagesGroup.edges | |
const postsPerPage = 10 | |
const numPages = Math.ceil(posts.length / postsPerPage) | |
Array.from({ length: numPages }).forEach((_, i) => { | |
createPage({ | |
path: i === 0 ? `/blog` : `/blog/page:${i + 1}`, | |
component: blogPage, | |
context: { | |
limit: postsPerPage, | |
skip: i * postsPerPage, | |
numPages, | |
currentPage: i + 1, | |
}, | |
}) | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment