feat: drafts frontmatter & exclude drafts from production

This commit is contained in:
草师傅 2025-08-18 18:26:04 +08:00
parent bfd3bef223
commit ca28bd2d36
Signed by: gb
GPG key ID: 43330A030E2D6478
12 changed files with 34 additions and 11 deletions

View file

@ -4,7 +4,9 @@ import {getCollection} from "astro:content";
import ArticleList from "../../components/ArticleList.astro";
export async function getStaticPaths() {
const allPosts = await getCollection('posts');
const allPosts = await getCollection('posts', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
});
// Get all categories, ensuring the default 'uncategorized' is used when categories is undefined
const uniqueCategories = [...new Set(allPosts.map((post: any) =>
post.data.categories || ['uncategorized']).flat())];