feat: optional dates, otherwise fetched from git
This commit is contained in:
parent
4d9e3c56da
commit
cc6eff22a8
8 changed files with 90 additions and 31 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue