feat: dates on blog posts, below the title

This commit is contained in:
Lewis Wynne 2026-01-23 20:57:01 +00:00
parent 9ef7a745fb
commit 996321a4d2
2 changed files with 12 additions and 0 deletions

View file

@ -12,11 +12,19 @@ export async function getStaticPaths() {
const { post } = Astro.props; const { post } = Astro.props;
const { Content } = await render(post); const { Content } = await render(post);
function formatDate(date: Date): string {
const d = String(date.getDate()).padStart(2, '0');
const m = String(date.getMonth() + 1).padStart(2, '0');
const y = String(date.getFullYear()).slice(-2);
return `${d}/${m}/${y}`;
}
--- ---
<Layout title={`${post.data.title} - lewis m.w.`}> <Layout title={`${post.data.title} - lewis m.w.`}>
<article> <article>
<h1>{post.data.title}</h1> <h1>{post.data.title}</h1>
<p class="muted" style="margin-top: 0;">{formatDate(post.data.date)}</p>
<Content /> <Content />
</article> </article>
</Layout> </Layout>

View file

@ -4,6 +4,10 @@ body {
padding: 1rem; padding: 1rem;
} }
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.25rem;
}
.muted { .muted {
color: #888; color: #888;
} }