feat: update blog content and scripts

This commit is contained in:
KazooTTT
2024-10-10 21:35:42 +08:00
parent 950d014fdb
commit d2f4fa5fec
77 changed files with 4973 additions and 4862 deletions

View File

@ -1,5 +1,13 @@
export { cn } from './tailwind'
export { getAllPosts, sortMDByDate, getUniqueTags, getUniqueTagsWithCount, getAllCategories, getUniqueCategories,getUniqueCategoriesWithCount } from './post'
export {
getAllPosts,
sortMDByDate,
getUniqueTags,
getUniqueTagsWithCount,
getAllCategories,
getUniqueCategories,
getUniqueCategoriesWithCount
} from './post'
export { getFormattedDate } from './date'
export { generateToc } from './generateToc'
export type { TocItem } from './generateToc'

View File

@ -40,10 +40,9 @@ export function getUniqueTagsWithCount(
/** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */
export function getAllCategories(posts: Array<CollectionEntry<'post'>>): string[] {
return posts.map(post => post.data.category ?? "未分类")
return posts.map((post) => post.data.category ?? '未分类')
}
/** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */
export function getUniqueCategories(posts: Array<CollectionEntry<'post'>>) {
return [...new Set(getAllCategories(posts))]
@ -62,8 +61,11 @@ export function getUniqueCategoriesWithCount(
}
export function getIdToSlugMap(posts: Array<CollectionEntry<'post'>>) {
return posts.reduce((acc, post) => {
acc[(post.id.split(".md")[0])] = post.slug
return acc
}, {} as Record<string, string>)
return posts.reduce(
(acc, post) => {
acc[post.id.split('.md')[0]] = post.slug
return acc
},
{} as Record<string, string>
)
}