Sort blog posts by publication date

This commit is contained in:
Valentin Popov 2024-09-12 21:02:35 +00:00
parent 4ac7da1231
commit 3591bebabf
Signed by: Valentin Popov
GPG Key ID: AE3CE523DAAA8401

View File

@ -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());
---
<Layout>