Sort posts before rendering

This commit is contained in:
2023-11-26 07:55:58 -06:00
parent e0b0ab45a3
commit d494391cee

View File

@@ -3,6 +3,7 @@ import { getCollection, getEntry } from "astro:content";
import Base from "@layouts/Base.astro";
import Summary from "@components/Summary.astro";
const posts = await getCollection("blog");
posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime());
---
<Base>