fix: cleanup frontend .svelte-kit
This commit is contained in:
parent
1e04a7be6f
commit
3ee3879db7
@ -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;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user