fix blog archive sorting
This commit is contained in:
@@ -1,7 +1,23 @@
|
|||||||
---
|
---
|
||||||
import { SEO } from "astro-seo";
|
import { SEO } from "astro-seo";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
|
||||||
const posts = await Astro.glob("./posts/*.md");
|
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">
|
<html lang="en">
|
||||||
|
|||||||
Reference in New Issue
Block a user