feat: some stuff
Some checks failed
Deploy to GitHub Pages / build (push) Failing after 14m41s
Deploy to GitHub Pages / deploy (push) Has been skipped

This commit is contained in:
2024-04-03 21:09:50 +02:00
parent d025f7e01b
commit 1e04a7be6f
46 changed files with 241 additions and 48 deletions

View File

@ -22,9 +22,10 @@ export function parseSlug(id: string) {
return [splitPath.join("/"), lang]
}
export function filterCollection<T extends { id: string, data: { date: Date } }>(collection: T[], locale: string): T[] {
export function filterCollection<T extends { id: string, data: { draft: boolean, date: Date } }>(collection: T[], locale: string): T[] {
return collection.filter(post => {
const [_, lang] = parseSlug(post?.id);
if (post?.data?.draft) return false;
return lang === locale;
}).sort((a, b) => {
return (a?.data?.date > b?.data?.date) ? -1 : 1;