2023-08-16 23:55:57 +08:00
|
|
|
import ListLayout from '@/layouts/ListLayoutWithTags';
|
|
|
|
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer';
|
|
|
|
import { allBlogs } from 'contentlayer/generated';
|
|
|
|
import { genPageMetadata } from 'app/seo';
|
2023-08-16 23:29:22 +08:00
|
|
|
|
2023-08-16 23:55:57 +08:00
|
|
|
const POSTS_PER_PAGE = 5;
|
2023-08-16 23:29:22 +08:00
|
|
|
|
2023-08-16 23:55:57 +08:00
|
|
|
export const metadata = genPageMetadata({ title: 'Blog' });
|
2023-08-16 23:29:22 +08:00
|
|
|
|
|
|
|
export default function BlogPage() {
|
2023-08-16 23:55:57 +08:00
|
|
|
const posts = allCoreContent(sortPosts(allBlogs));
|
|
|
|
const pageNumber = 1;
|
2023-08-16 23:29:22 +08:00
|
|
|
const initialDisplayPosts = posts.slice(
|
|
|
|
POSTS_PER_PAGE * (pageNumber - 1),
|
2023-08-16 23:55:57 +08:00
|
|
|
POSTS_PER_PAGE * pageNumber,
|
|
|
|
);
|
2023-08-16 23:29:22 +08:00
|
|
|
const pagination = {
|
|
|
|
currentPage: pageNumber,
|
|
|
|
totalPages: Math.ceil(posts.length / POSTS_PER_PAGE),
|
2023-08-16 23:55:57 +08:00
|
|
|
};
|
2023-08-16 23:29:22 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ListLayout
|
|
|
|
posts={posts}
|
|
|
|
initialDisplayPosts={initialDisplayPosts}
|
|
|
|
pagination={pagination}
|
|
|
|
title="All Posts"
|
|
|
|
/>
|
2023-08-16 23:55:57 +08:00
|
|
|
);
|
2023-08-16 23:29:22 +08:00
|
|
|
}
|