fix blog archive sorting

This commit is contained in:
2024-07-09 18:13:56 +02:00
parent 5e79a68ac2
commit 293983eeb1

View File

@@ -1,7 +1,23 @@
---
import { SEO } from "astro-seo";
import { format } from "date-fns";
const posts = await Astro.glob("./posts/*.md");
posts.sort((a, b) => {
const dateA = new Date(a.frontmatter.pubDate);
const dateB = new Date(b.frontmatter.pubDate);
if (dateA === dateB) {
return 0;
}
if (dateA < dateB) {
return 1;
}
return -1;
});
---
<html lang="en">