分页预渲染,分页组件优化
This commit is contained in:
tangly1024
2022-01-05 16:59:19 +08:00
parent 8baaf673d3
commit a5cbfb9b08
2 changed files with 2 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ const PaginationNumber = ({ page, showNext, totalPage }) => {
}
function getPageElement (page, currentPage) {
return <Link href={`/page/${page}`} key={page} passHref>
return <Link href={page === 1 ? '/' : `/page/${page}`} key={page} passHref>
<a className={(page + '' === currentPage + '' ? 'font-bold bg-gray-500 dark:bg-gray-400 text-white ' : 'border-t-2 duration-500 border-white hover:border-gray-400 ') +
' border-white dark:border-gray-700 dark:hover:border-gray-400 cursor-pointer w-6 text-center font-light hover:font-bold'}>
{page}

View File

@@ -31,9 +31,7 @@ export async function getStaticPaths () {
const totalPages = Math.ceil(allPosts / BLOG.postsPerPage)
return {
// remove first page, we 're not gonna handle that.
paths: Array.from({ length: totalPages - 1 }, (_, i) => ({
params: { page: '' + (i + 2) }
})),
paths: Array.from({ length: totalPages - 1 }, (_, i) => `/page/${(i + 2)}`),
fallback: true
}
}