jonbio/app/blog/page.tsx

31 lines
809 B
TypeScript
Raw Normal View History

2023-07-29 12:31:36 +08:00
import ListLayout from '@/layouts/ListLayoutWithTags'
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer'
2023-07-07 11:17:22 +08:00
import { allBlogs } from 'contentlayer/generated'
2023-07-08 21:03:46 +08:00
import { genPageMetadata } from 'app/seo'
2023-07-07 11:17:22 +08:00
const POSTS_PER_PAGE = 5
2023-07-08 21:03:46 +08:00
export const metadata = genPageMetadata({ title: 'Blog' })
2023-07-07 11:17:22 +08:00
export default function BlogPage() {
const posts = allCoreContent(sortPosts(allBlogs))
2023-07-07 11:17:22 +08:00
const pageNumber = 1
const initialDisplayPosts = posts.slice(
POSTS_PER_PAGE * (pageNumber - 1),
POSTS_PER_PAGE * pageNumber
)
const pagination = {
currentPage: pageNumber,
totalPages: Math.ceil(posts.length / POSTS_PER_PAGE),
}
return (
2023-07-16 18:52:51 +08:00
<ListLayout
posts={posts}
initialDisplayPosts={initialDisplayPosts}
pagination={pagination}
title="All Posts"
/>
2023-07-07 11:17:22 +08:00
)
}