fix: cleanup frontend .svelte-kit
Some checks failed
Deploy to GitHub Pages / build (push) Successful in 25m41s
Deploy to GitHub Pages / deploy (push) Failing after 2s

This commit is contained in:
max_richter 2024-04-05 19:40:09 +02:00
parent 1e04a7be6f
commit 3ee3879db7

View File

@ -22,12 +22,13 @@ export function parseSlug(id: string) {
return [splitPath.join("/"), lang]
}
export function filterCollection<T extends { id: string, data: { draft: boolean, 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) => {
if (!a?.data?.date || !b?.data?.date) return 0;
return (a?.data?.date > b?.data?.date) ? -1 : 1;
});
}