slug,page 预渲染

This commit is contained in:
tangly1024
2022-01-06 12:45:12 +08:00
parent a5cbfb9b08
commit 514a858051
2 changed files with 4 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ export async function getStaticPaths () {
posts = await getAllPosts({ from: 'slug - paths', includePage: true })
}
return {
paths: posts.map(row => `${BLOG.path}/article/${row.slug}`),
paths: posts.map(row => ({ params: { slug: row.slug } })),
fallback: true
}
}

View File

@@ -28,10 +28,10 @@ export async function getStaticPaths () {
const from = 'page'
const notionPageData = await getNotionPageData({ from })
const allPosts = await getAllPosts({ notionPageData, from })
const totalPages = Math.ceil(allPosts / BLOG.postsPerPage)
const totalPages = Math.ceil(allPosts?.length / BLOG.postsPerPage)
return {
// remove first page, we 're not gonna handle that.
paths: Array.from({ length: totalPages - 1 }, (_, i) => `/page/${(i + 2)}`),
paths: Array.from({ length: totalPages - 1 }, (_, i) => ({ params: { page: '' + (i + 2) } })),
fallback: true
}
}
@@ -44,7 +44,7 @@ export async function getStaticProps ({ params: { page } }) {
const tagOptions = notionPageData.tagOptions
const tags = await getAllTags({ allPosts, tagOptions })
const meta = {
title: `${BLOG.title}`,
title: `Page ${page} |${BLOG.title}`,
description: BLOG.description,
type: 'website'
}