From b9ad4143a59fe0b1f4755018b845992d3970ce18 Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Sat, 17 Feb 2024 08:45:15 +0400 Subject: [PATCH] Handle optional 'tags' field in blog posts A conditional chaining operator has been added while mapping over post data tags to handle cases where the 'tags' field might not be present. This prevents the application from crashing in case 'tags' is undefined for a particular blog post. --- src/pages/blog/[...slug].astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index cb5ea3c..dedb47e 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -84,7 +84,7 @@ const { post } = Astro.props;
{ - post.data.tags.map((tag: string) => ( + post.data.tags?.map((tag: string) => ( {capitalize(tag)}