diff --git a/src/pages/blog.astro b/src/pages/blog.astro index 6c46e0e..4b94846 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -2,6 +2,11 @@ import Navbar from '../components/Navbar.astro' const posts = await Astro.glob('./posts/*.md'); +const sortedPosts = posts.sort((a, b) => { + const splitA = a.frontmatter.date.split("/"); + const splitB = b.frontmatter.date.split("/"); + return new Date(splitB[1], splitB[0], splitB[2]).getTime() - new Date(splitA[1], splitA[0], splitA[2]).getTime() +}); ---
@@ -10,7 +15,7 @@ const posts = await Astro.glob('./posts/*.md');