mirror of
https://github.com/KazooTTT/kazoottt-blog.git
synced 2025-06-22 02:01:32 +08:00
docs: update
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user