Fixes error due to missing date
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user