docs: update

This commit is contained in:
KazooTTT
2024-11-26 00:22:13 +08:00
parent 92fc8c7861
commit 504a9414e8
58 changed files with 2584 additions and 46 deletions

View File

@ -4,7 +4,7 @@ import { getCollection } from 'astro:content'
/** Note: this function filters out draft posts based on the environment */
export async function getAllPosts() {
return await getCollection('post', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true
return !data.draft && !data.category?.startsWith('日记-20')
})
}
@ -12,6 +12,16 @@ export async function getAllSortedPosts() {
return sortMDByDate(await getAllPosts())
}
export const getallDiaries = async () => {
return await getCollection('post', ({ data }) => {
return !data.draft && data.category?.startsWith('日记-20')
})
}
export const getallDiariesSorted = async () => {
return sortMDByDate(await getallDiaries())
}
export function sortMDByDate(posts: Array<CollectionEntry<'post'>>) {
return posts.sort((a, b) => {
const aDate = new Date(a.data.date).valueOf()