From 38f2677cd28de7d28fcbefa9f9848aaf3d235690 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 12 Oct 2025 11:18:18 -0400 Subject: [PATCH] fix: sorting --- src/pages/gist.astro | 9 ++++++++- src/pages/git.astro | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pages/gist.astro b/src/pages/gist.astro index 9e3b6b7..b74537e 100644 --- a/src/pages/gist.astro +++ b/src/pages/gist.astro @@ -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); +}); --- diff --git a/src/pages/git.astro b/src/pages/git.astro index 1f25aba..6c279fa 100644 --- a/src/pages/git.astro +++ b/src/pages/git.astro @@ -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); +}); ---