--- import Layout from "../layouts/Layout.astro"; import { getCollection, type CollectionEntry } from "astro:content"; import { config } from "../config"; // 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(), ); function formatDate(date: Date): string { return date.toLocaleDateString("en-us", { month: "short", day: "numeric", year: "numeric", }); } ---

Posts

{ sortedPosts.length === 0 ? (

No posts available yet. Check back soon!

) : ( ) }