Replace local functions with getSortedPosts function

This commit is contained in:
Sat Naing
2022-09-10 16:23:06 +06:30
parent a0d850c130
commit 92c0ed3a71
2 changed files with 4 additions and 10 deletions
+2 -5
View File
@@ -5,14 +5,11 @@ import Footer from "@components/Footer.astro";
import Main from "@layouts/Main.astro";
import Card from "@components/Card.astro";
import type { Frontmatter } from "../index.astro";
import getSortedPosts from "src/utils/getSortedPosts";
const posts = await Astro.glob<Frontmatter>("./*.md");
const sortedPosts = posts.sort(
(a, b) =>
Math.floor(new Date(b.frontmatter.datetime).getTime() / 1000) -
Math.floor(new Date(a.frontmatter.datetime).getTime() / 1000)
);
const sortedPosts = getSortedPosts(posts);
---
<Layout title="Welcome to Astro.">