--- import { getCollection, type CollectionEntry } from "astro:content"; import Timestamp from "./Timestamp.astro"; import { sortBy } from "lodash-es"; interface Props { basePath: string; includeDrafts?: boolean; } type Post = CollectionEntry<"posts">; const { basePath, includeDrafts } = Astro.props; const filter = includeDrafts ? (_: Post) => true : (post: Post) => !post.data.draft; const allPosts = await getCollection("posts", filter); const sortedPosts = sortBy(allPosts, (post) => -post.data.date); --- { sortedPosts.map((post) => { return ( ); }) }
{post.data.title}