--- import { getEmDashCollection, getEntryTerms } from "emdash"; import Base from "../../layouts/Base.astro"; import { getReadingTime } from "../../utils/reading-time"; const { entries: posts, cacheHint } = await getEmDashCollection("posts"); Astro.cache.set(cacheHint); const sortedPosts = posts.toSorted((a, b) => { const dateA = a.data.publishedAt?.getTime() ?? 0; const dateB = b.data.publishedAt?.getTime() ?? 0; return dateB - dateA; }); // Fetch tags for each post (bylines are already hydrated by getEmDashCollection) const postsWithTags = await Promise.all( sortedPosts.map(async (post) => { const tags = await getEntryTerms("posts", post.data.id, "tag"); const bylines = post.data.bylines ?? []; return { post, tags, bylines }; }) ); const formatDate = (date: Date) => date.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }); ---
{ sortedPosts.length === 0 ? (

No posts yet.

) : (
{postsWithTags.map(({ post, tags, bylines }) => ( ))}
) }