mirror of
https://github.com/KazooTTT/kazoottt-blog.git
synced 2025-06-24 03:01:31 +08:00
feat: update blog content and scripts
This commit is contained in:
@ -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'
|
||||
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user