Fixes error due to missing date

This commit is contained in:
2025-07-31 14:59:14 -07:00
parent 96ee56fc1f
commit 75c9322fd0
2 changed files with 9 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ const { title, description, pubDate, updatedDate, heroImage } = Astro.props;
<div class="prose">
<div class="title">
<div class="date">
<FormattedDate date={pubDate} />
{ pubDate && <FormattedDate date={pubDate} /> }
{
updatedDate && (
<div class="last-updated-on">

View File

@@ -1,12 +1,15 @@
---
import NotchedBox from '../../components/NotchedBox.astro';
import RootLayout from '../../layouts/RootLayout.astro';
import { getCollection } from 'astro:content';
import { getCollection, type CollectionEntry } from 'astro:content';
import FormattedDate from '../../components/FormattedDate.astro';
import { Image } from 'astro:assets';
const posts = (await getCollection('blog'))
.filter(p => p.data.pubDate)
function publishedOnly(p: CollectionEntry<'blog'>): p is (CollectionEntry<'blog'> & { data: { pubDate: Date }}) {
return p.data.pubDate !== undefined;
}
const posts = (await getCollection('blog', publishedOnly))
.sort(
(a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(),
);
@@ -57,7 +60,8 @@ const posts = (await getCollection('blog'))
{ post.data.description &&
<p class="description">
{post.data.description}
</p>}
</p>
}
</div>
</NotchedBox>
</a>