main
1---
2import { getCollection } from "astro:content";
3import PostsList from "@/components/PostsList.astro";
4import { SITE_CONFIG } from "@/config";
5import Article from "@/contents/home.typ";
6import GlobalLayout from "@/layouts/GlobalLayout.astro";
7
8const posts = await getCollection("posts");
9const sortedPosts = posts.sort(
10 (a, b) => b.data.date.getTime() - a.data.date.getTime(),
11);
12---
13
14<GlobalLayout>
15 <article>
16 <h1>{SITE_CONFIG.title}</h1>
17 <Article />
18 <h2 id="recent-posts">Recent Posts</h2>
19 <PostsList posts={sortedPosts.slice(0, 4)} />
20 </article>
21</GlobalLayout>