mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Add posts page
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
import Footer from "@components/Footer.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Card from "@components/Card.astro";
|
||||
import type { Frontmatter } from "../index.astro";
|
||||
|
||||
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)
|
||||
);
|
||||
---
|
||||
|
||||
<Layout title="Welcome to Astro.">
|
||||
<Header />
|
||||
<Main pageTitle="Posts" pageDesc="All the tags used in posts.">
|
||||
<ul>
|
||||
{
|
||||
sortedPosts.map((post) => (
|
||||
<Card href={post.url} post={post.frontmatter} />
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</Main>
|
||||
<Footer />
|
||||
</Layout>
|
||||
Reference in New Issue
Block a user