添加系列栏

This commit is contained in:
mckero committed 2025-08-26 02:50:07 +00:00
1 parent 841d47019d
commit 3b4d3195bd
16 files changed
+90 -3

No files matched your search

+19
View File
@@ -112,3 +112,22 @@ export async function getCategoryList(): Promise<Category[]> {
}
return ret;
}
export async function getPostSeries(
seriesName: string,
): Promise<{ body: string; data: BlogPostData; slug: string }[]> {
const posts = (await getCollection('posts', ({ data }) => {
return (
(import.meta.env.PROD ? data.draft !== true : true) &&
data.series === seriesName
)
})) as unknown as { body: string; data: BlogPostData; slug: string }[]
posts.sort((a, b) => {
const dateA = new Date(a.data.published)
const dateB = new Date(b.data.published)
return dateA > dateB ? 1 : -1
})
return posts
}