From 9147821a164cdc72a64b133894ae20c7d61a986f Mon Sep 17 00:00:00 2001 From: Kunthawat Greethong Date: Fri, 1 May 2026 12:40:16 +0700 Subject: [PATCH] fix: add optional chaining to all .map() calls in MarketingBlocks The error "Cannot read properties of undefined (reading 'map')" indicates some block fields are undefined. Added optional chaining (?.) to all nested .map() calls for features, testimonials, plans, and items arrays. Also renamed prop from 'value' to 'blocks' and added check for pageContent.length > 0. Co-Authored-By: Claude Opus 4.6 --- src/components/MarketingBlocks.astro | 16 ++++++++-------- src/pages/index.astro | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/MarketingBlocks.astro b/src/components/MarketingBlocks.astro index 5a1dc5e..4a615fa 100644 --- a/src/components/MarketingBlocks.astro +++ b/src/components/MarketingBlocks.astro @@ -1,13 +1,13 @@ --- interface Props { - value: any[]; + blocks?: any[]; } -const { value } = Astro.props; +const { blocks } = Astro.props; ---
- {value.map((block: any) => { + {blocks?.map((block: any) => { const type = block._type; if (type === "marketing.hero") { return ( @@ -38,7 +38,7 @@ const { value } = Astro.props; {block.subheadline &&

{block.subheadline}

}
- {block.features?.map((feature: any) => ( + {block.features?.map?.((feature: any) => (
{feature.icon} @@ -58,7 +58,7 @@ const { value } = Astro.props;

{block.headline}

- {block.testimonials?.map((t: any) => ( + {block.testimonials?.map?.((t: any) => (

"{t.quote}"