This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
import ListLayout from '@/layouts/ListLayoutWithTags'
|
||||
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer'
|
||||
import { allBlogs } from 'contentlayer/generated'
|
||||
import ListLayout from '@/layouts/ListLayoutWithTags';
|
||||
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer';
|
||||
import { allBlogs } from 'contentlayer/generated';
|
||||
|
||||
const POSTS_PER_PAGE = 5
|
||||
const POSTS_PER_PAGE = 5;
|
||||
|
||||
export const generateStaticParams = async () => {
|
||||
const totalPages = Math.ceil(allBlogs.length / POSTS_PER_PAGE)
|
||||
const paths = Array.from({ length: totalPages }, (_, i) => ({ page: (i + 1).toString() }))
|
||||
const totalPages = Math.ceil(allBlogs.length / POSTS_PER_PAGE);
|
||||
const paths = Array.from({ length: totalPages }, (_, i) => ({
|
||||
page: (i + 1).toString(),
|
||||
}));
|
||||
|
||||
return paths
|
||||
}
|
||||
return paths;
|
||||
};
|
||||
|
||||
export default function Page({ params }: { params: { page: string } }) {
|
||||
const posts = allCoreContent(sortPosts(allBlogs))
|
||||
const pageNumber = parseInt(params.page as string)
|
||||
const posts = allCoreContent(sortPosts(allBlogs));
|
||||
const pageNumber = parseInt(params.page as string);
|
||||
const initialDisplayPosts = posts.slice(
|
||||
POSTS_PER_PAGE * (pageNumber - 1),
|
||||
POSTS_PER_PAGE * pageNumber
|
||||
)
|
||||
POSTS_PER_PAGE * pageNumber,
|
||||
);
|
||||
const pagination = {
|
||||
currentPage: pageNumber,
|
||||
totalPages: Math.ceil(posts.length / POSTS_PER_PAGE),
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ListLayout
|
||||
@@ -30,5 +32,5 @@ export default function Page({ params }: { params: { page: string } }) {
|
||||
pagination={pagination}
|
||||
title="All Posts"
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user