fix: 修改rss生成逻辑,修改目录生成逻辑

This commit is contained in:
KazooTTT
2024-11-30 16:43:18 +08:00
parent 09cd161c84
commit 89911d9e63
8 changed files with 5008 additions and 6165 deletions

View File

@ -22,6 +22,14 @@ export const getAllDiariesSorted = async (): Promise<CollectionEntry<'post'>[]>
return sortMDByDate(await getAllDiaries())
}
export const getSortedAllPostsAndDiaries = async (): Promise<CollectionEntry<'post'>[]> => {
const posts = await getCollection('post', ({ data }: { data: CollectionEntry<'post'> }) => {
return !data.draft
})
return sortMDByDate(posts)
}
export function sortMDByDate(posts: Array<CollectionEntry<'post'>>): CollectionEntry<'post'>[] {
return posts.sort((a, b) => {
const aDate = new Date(a.data.date).valueOf()