From 3591bebabff902106632f0f0b309f3baa1e04a17 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 12 Sep 2024 21:02:35 +0000 Subject: [PATCH] Sort blog posts by publication date --- src/pages/index.astro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/index.astro b/src/pages/index.astro index 6df8f31..6575ca6 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,6 +4,7 @@ import Element from "../components/PostElement.astro"; import Layout from "../layouts/BaseLayout.astro"; const posts = await getCollection("blog"); +posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime()); ---