Finalized
This commit is contained in:
@ -3,12 +3,12 @@ import Layout from "../layouts/Layout.astro";
|
||||
import { getCollection, type CollectionEntry } from "astro:content";
|
||||
import PostCard from "../components/PostCard.astro";
|
||||
|
||||
// Get all blog posts from the content collection
|
||||
const posts = await getCollection("blog");
|
||||
// Get all posts from the content collection
|
||||
const posts = await getCollection("posts");
|
||||
|
||||
// Sort posts by date, newest first
|
||||
const sortedPosts = posts.sort(
|
||||
(a: CollectionEntry<"blog">, b: CollectionEntry<"blog">) => new Date(b.data.pubDate).valueOf() - new Date(a.data.pubDate).valueOf()
|
||||
(a: CollectionEntry<"posts">, b: CollectionEntry<"posts">) => new Date(b.data.pubDate).valueOf() - new Date(a.data.pubDate).valueOf()
|
||||
);
|
||||
---
|
||||
|
||||
@ -18,7 +18,7 @@ const sortedPosts = posts.sort(
|
||||
Posts
|
||||
</h1>
|
||||
<div class="flex flex-row flex-wrap justify-center gap-4 sm:gap-6 max-w-6xl mx-auto">
|
||||
{sortedPosts.map((post: CollectionEntry<"blog">) => (
|
||||
{sortedPosts.map((post: CollectionEntry<"posts">) => (
|
||||
<PostCard post={post} />
|
||||
))}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user