fix: sorting

This commit is contained in:
Barrett Ruth 2025-10-12 11:18:18 -04:00
parent 10a9d87926
commit 38f2677cd2
2 changed files with 16 additions and 2 deletions

View file

@ -4,7 +4,14 @@ import { getCollection } from "astro:content";
const title = "gists";
const gists = await getCollection("gists");
gists.sort((a, b) => a.slug.localeCompare(b.slug));
gists.sort((a, b) => {
const parseEuroDate = (dateStr) => {
if (!dateStr) return new Date(0);
const [day, month, year] = (dateStr || "").split("/");
return new Date(year, month - 1, day);
};
return parseEuroDate(b.data.date) - parseEuroDate(a.data.date);
});
---
<BaseLayout title={title}>

View file

@ -4,7 +4,14 @@ import { getCollection } from "astro:content";
const title = "git repos";
const repos = await getCollection("git");
repos.sort((a, b) => a.slug.localeCompare(b.slug));
repos.sort((a, b) => {
const parseEuroDate = (dateStr) => {
if (!dateStr) return new Date(0);
const [day, month, year] = (dateStr || "").split("/");
return new Date(year, month - 1, day);
};
return parseEuroDate(b.data.date) - parseEuroDate(a.data.date);
});
---
<BaseLayout title={title}>