diff --git a/js/src/components/Post/PostListItem.vue b/js/src/components/Post/PostListItem.vue
index 4ec0f723..8871a285 100644
--- a/js/src/components/Post/PostListItem.vue
+++ b/js/src/components/Post/PostListItem.vue
@@ -18,7 +18,7 @@
- {{
+ {{
formatDateTimeString(
publishedAt.toString(),
undefined,
@@ -26,7 +26,7 @@
"short"
)
}}
- {{
+ {{
formatDistanceToNow(publishedAt, {
locale: dateFnsLocale,
addSuffix: true,
@@ -75,30 +75,22 @@ const dateFnsLocale = inject("dateFnsLocale");
const postTags = computed(() => (props.post.tags ?? []).slice(0, 3));
-const publishedAt = computed((): Date => {
- return new Date((props.post.publishAt ?? props.post.insertedAt) as Date);
+const publishedAt = computed((): Date | undefined => {
+ const date = props.post.publishAt ?? props.post.insertedAt;
+ if (!date) return undefined;
+ return new Date(date);
});
const isBeforeLastWeek = computed((): boolean => {
- return isBefore(publishedAt.value, subWeeks(new Date(), 1));
+ return (
+ publishedAt.value !== undefined &&
+ isBefore(publishedAt.value, subWeeks(new Date(), 1))
+ );
});