aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/index.astro
blob: 48d33e81651034fe31942c1419ece60592b94dbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
import { getCollection } from "astro:content";
import Layout from "../../layouts/BaseLayout.astro";
import PostElement from "../../components/PostElement.astro";

const posts = await getCollection("blog", ({ data }) => {
	return data.draft !== true;
});

posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
---

<Layout>
	<section style={{ "margin-top": "3rem" }}>
		<ul>
			{posts.map((post) => <PostElement post={post} />)}
		</ul>
	</section>
</Layout>