feat: optional dates, otherwise fetched from git

This commit is contained in:
Lewis Wynne 2026-01-31 23:39:29 +00:00
parent 4d9e3c56da
commit cc6eff22a8
8 changed files with 90 additions and 31 deletions

View file

@ -2,13 +2,13 @@
import { getCollection, render } from 'astro:content';
import Layout from '../../layouts/Layout.astro';
import { formatDate } from '../../lib/format';
import { getSlug } from '../../lib/md';
import { getSlug, enrichPostWithDates } from '../../lib/md';
export async function getStaticPaths() {
const posts = await getCollection('md', ({ data }) => data.draft !== true);
return posts.map(post => ({
params: { slug: getSlug(post.id) },
props: { post }
props: { post: enrichPostWithDates(post) }
}));
}
@ -19,7 +19,7 @@ const { Content } = await render(post);
<article>
<h1>{post.data.title}</h1>
<p class="muted" style="margin-top: 0;">{formatDate(post.data.date)}</p>
<p class="muted" style="margin-top: 0;">{formatDate(post.dates.created)}{post.dates.updated && ` (updated ${formatDate(post.dates.updated)})`}</p>
<Content />
</article>
</Layout>