Files
ghall.space/src/pages/blog/index.astro
T
2025-02-06 19:12:41 -05:00

29 lines
546 B
Plaintext

---
import { getCollection } from 'astro:content';
import Layout from '@layouts/Layout.astro';
import PostPreview from '@components/PostPreview.astro';
const posts = await getCollection('blog');
---
<Layout title="Home">
{
posts
.sort(
(a, b) =>
new Date(b.data.pubDate).valueOf() -
new Date(a.data.pubDate).valueOf()
)
.slice(0, 10)
.map((post) => <PostPreview post={post} />)
}
{
posts.length < 6 ? null : (
<div class="more-posts">
<a href="blog/archive/all">All Posts</a>
</div>
)
}
</Layout>