From 6665edcd48046c987d7497d84321e5f17d5862d2 Mon Sep 17 00:00:00 2001 From: Cassidy Williams <1454517+cassidoo@users.noreply.github.com> Date: Sun, 26 Feb 2023 22:06:45 -0600 Subject: [PATCH] Sort tag pages by date instead of name --- src/pages/tag/[tag].astro | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/tag/[tag].astro b/src/pages/tag/[tag].astro index a80995a..bf2370e 100644 --- a/src/pages/tag/[tag].astro +++ b/src/pages/tag/[tag].astro @@ -33,6 +33,12 @@ export async function getStaticPaths() { const { tag } = Astro.props; const { tag: currentTag } = Astro.params; + +let sortedPosts = tag.sort( + (a, b) => + new Date(b.frontmatter.added).valueOf() - + new Date(a.frontmatter.added).valueOf() +); --- @@ -45,7 +51,7 @@ const { tag: currentTag } = Astro.params;