diff --git a/src/components/blog/Hero.astro b/src/components/blog/Hero.astro index 54430a9..af15ebb 100644 --- a/src/components/blog/Hero.astro +++ b/src/components/blog/Hero.astro @@ -76,7 +76,7 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = {
- {data.tags.map((tag) => ( + {data.tags?.map((tag) => ( new Date(val)), coverImage: z.string().optional(), draft: z.boolean().default(false), - tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase), + tags: z.array(z.string()).optional().default([]).transform(removeDupsAndLowerCase), ogImage: z.string().optional(), category: z.string().optional().nullable(), finished: z.boolean().default(false) diff --git a/src/pages/tags/[tag]/[...page].astro b/src/pages/tags/[tag]/[...page].astro index d0af14c..1526b07 100644 --- a/src/pages/tags/[tag]/[...page].astro +++ b/src/pages/tags/[tag]/[...page].astro @@ -16,7 +16,7 @@ export const getStaticPaths: GetStaticPaths = async ({ paginate }) => { const uniqueTags = getUniqueTags(allPostsByDate) return uniqueTags.flatMap((tag) => { - const filterPosts = allPostsByDate.filter((post) => post.data.tags.includes(tag)) + const filterPosts = allPostsByDate.filter((post) => post.data.tags?.includes(tag)) return paginate(filterPosts, { pageSize: 50, params: { tag } diff --git a/src/utils/post.ts b/src/utils/post.ts index edda03c..3eca3c4 100644 --- a/src/utils/post.ts +++ b/src/utils/post.ts @@ -18,7 +18,7 @@ export function sortMDByDate(posts: Array>) { /** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */ export function getAllTags(posts: Array>) { - return posts.flatMap((post) => [...post.data.tags]) + return posts.flatMap((post) => [...(post.data?.tags ?? [])]) } /** Note: This function doesn't filter draft posts, pass it the result of getAllPosts above to do so. */