fix: filter out draft posts in pagination and tag collection
This commit is contained in:
parent
6b831e7100
commit
9862f3fa24
4 changed files with 8 additions and 5 deletions
|
|
@ -13,8 +13,9 @@ export async function getStaticPaths({
|
|||
paginate: PaginateFunction;
|
||||
}) {
|
||||
const posts = await getCollection("blog");
|
||||
posts.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());
|
||||
return paginate(posts, { pageSize: 5 });
|
||||
const filteredPosts = posts.filter((post) => !post.data.draft);
|
||||
filteredPosts.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());
|
||||
return paginate(filteredPosts, { pageSize: 10 });
|
||||
}
|
||||
|
||||
interface Props {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue