feat: 允许tags不存在

This commit is contained in:
KazooTTT
2024-10-16 10:45:32 +08:00
parent a8ded02f4a
commit 5b6bd29c15
4 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ export function sortMDByDate(posts: Array<CollectionEntry<'post'>>) {
/** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */
export function getAllTags(posts: Array<CollectionEntry<'post'>>) {
return posts.flatMap((post) => [...post.data.tags])
return posts.flatMap((post) => [...(post.data?.tags ?? [])])
}
/** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */