fix: filter out draft posts in pagination and tag collection

This commit is contained in:
fiatcode 2026-01-22 18:46:14 +07:00
parent 6b831e7100
commit 9862f3fa24
4 changed files with 8 additions and 5 deletions

View file

@ -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 {