fix draft post display and improve typings
This commit is contained in:
@ -1,20 +1,18 @@
|
||||
import ListLayout from '@/layouts/ListLayout'
|
||||
import { allCoreContent, sortedBlogPost } from 'pliny/utils/contentlayer'
|
||||
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer'
|
||||
import { allBlogs } from 'contentlayer/generated'
|
||||
import type { Blog } from 'contentlayer/generated'
|
||||
|
||||
const POSTS_PER_PAGE = 5
|
||||
|
||||
export const generateStaticParams = async () => {
|
||||
const totalPosts = allBlogs
|
||||
const totalPages = Math.ceil(totalPosts.length / POSTS_PER_PAGE)
|
||||
const totalPages = Math.ceil(allBlogs.length / POSTS_PER_PAGE)
|
||||
const paths = Array.from({ length: totalPages }, (_, i) => ({ page: (i + 1).toString() }))
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
export default function Page({ params }: { params: { page: string } }) {
|
||||
const posts = sortedBlogPost(allBlogs) as Blog[]
|
||||
const posts = allCoreContent(sortPosts(allBlogs))
|
||||
const pageNumber = parseInt(params.page as string)
|
||||
const initialDisplayPosts = posts.slice(
|
||||
POSTS_PER_PAGE * (pageNumber - 1),
|
||||
@ -27,8 +25,8 @@ export default function Page({ params }: { params: { page: string } }) {
|
||||
|
||||
return (
|
||||
<ListLayout
|
||||
posts={allCoreContent(posts)}
|
||||
initialDisplayPosts={allCoreContent(initialDisplayPosts)}
|
||||
posts={posts}
|
||||
initialDisplayPosts={initialDisplayPosts}
|
||||
pagination={pagination}
|
||||
title="All Posts"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user