feat: some stuff
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user