From 23c7970cbcc4fcd7c2628133e765056953d2f9b3 Mon Sep 17 00:00:00 2001 From: John Kilpatrick Date: Sun, 8 Jan 2023 23:05:09 +0000 Subject: [PATCH] fix: Tag pages not sorting by date --- src/pages/tags/[tag].astro | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/tags/[tag].astro b/src/pages/tags/[tag].astro index 5127fc5..30e6148 100644 --- a/src/pages/tags/[tag].astro +++ b/src/pages/tags/[tag].astro @@ -34,6 +34,15 @@ const { tag } = Astro.params;

#{tag}

- {posts.map((post) => )} + { + posts + // Reverse chronological order + .sort( + (a, b) => + new Date(b.frontmatter.datePublished).getTime() - + new Date(a.frontmatter.datePublished).getTime() + ) + .map((post) => ) + }