--- import Layout from "../layouts/Layout.astro"; import { getCollection, type CollectionEntry } from "astro:content"; import PostCard from "../components/PostCard.astro"; // Get all posts from the content collection const posts = await getCollection("posts"); // Sort posts by date, newest first const sortedPosts = posts.sort( (a: CollectionEntry<"posts">, b: CollectionEntry<"posts">) => new Date(b.data.pubDate).valueOf() - new Date(a.data.pubDate).valueOf(), ); ---

Posts

{sortedPosts.map((post) => ( ))}
{ sortedPosts.length === 0 && (

No posts available yet. Check back soon!

) }