feat: personalize blog and update configurations

This commit is contained in:
KazooTTT
2025-02-05 20:35:05 +08:00
parent 4f55d62fb6
commit f22b2529e8
20 changed files with 314 additions and 50 deletions

View File

@ -1,3 +1,4 @@
import { collectionDateSort } from "@/utils/date";
import { type CollectionEntry, getCollection } from "astro:content";
/** filter out draft posts based on the environment */
@ -7,6 +8,14 @@ export async function getAllPosts(): Promise<CollectionEntry<"post">[]> {
});
}
export async function getAllCollectionPosts() {
const posts = await getAllPosts();
const notes = await getCollection("note");
const allPosts = [...posts, ...notes];
const allPostsSortedByDate = allPosts.sort(collectionDateSort);
return allPostsSortedByDate;
}
/** groups posts by year (based on option siteConfig.sortPostsByUpdatedDate), using the year as the key
* Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so.
*/