WIP work on adding support for profile page

This commit is contained in:
Corbin Crutchley
2019-10-24 15:07:02 -07:00
parent 65ea1f65c5
commit f0e52dc414
4 changed files with 51 additions and 28 deletions

View File

@@ -120,7 +120,7 @@ exports.createPages = ({ graphql, actions }) => {
})
})
const postsPerPage = 6;
const postsPerPage = 3;
const numberOfPages = Math.ceil(posts.length / postsPerPage)
createPage({
@@ -151,13 +151,38 @@ exports.createPages = ({ graphql, actions }) => {
}
unicorns.forEach((unicorn) => {
const uniPosts = posts.filter(({node: {frontmatter}}) => frontmatter.author.id === unicorn.node.id);
const numberOfUniPages = Math.ceil(uniPosts.length / postsPerPage)
createPage({
path: `unicorns/${unicorn.node.id}`,
component: blogProfile,
context: {
slug: unicorn.node.id,
limitNumber: postsPerPage,
skipNumber: 0,
pageIndex: 1,
numberOfUniPages
},
})
for (const i of Array(numberOfPages).keys()) {
if (i === 0) continue;
const pageNum = i + 1;
const skipNumber = postsPerPage * i;
createPage({
path: `unicorns/${unicorn.node.id}/page/${pageNum}`,
component: blogProfile,
context: {
slug: unicorn.node.id,
limitNumber: postsPerPage,
skipNumber,
pageIndex: pageNum,
numberOfUniPages
}
})
}
})
return null