hide projects too

This commit is contained in:
2026-09-10 00:26:59 -05:00
parent eae5d0effe
commit a788c71edf
7 changed files with 33 additions and 8 deletions
+14
View File
@@ -5,6 +5,20 @@ export function projectEntryHref(page: {
return page.href || `/projects${page.path}`;
}
export function sortProjects<
T extends { title: string; date?: Date | string | null },
>(pages: T[]) {
return [...pages].sort((a, b) => {
const aTime = a.date ? new Date(a.date).getTime() : Number.NaN;
const bTime = b.date ? new Date(b.date).getTime() : Number.NaN;
const aHasDate = !Number.isNaN(aTime);
const bHasDate = !Number.isNaN(bTime);
if (aHasDate && bHasDate && aTime !== bTime) return bTime - aTime;
if (aHasDate !== bHasDate) return aHasDate ? -1 : 1;
return a.title.localeCompare(b.title);
});
}
export function isExternalHref(href: string) {
return /^https?:\/\//i.test(href);
}