From cca5235310d3fafdf4f845fa10d1f3619a2136b5 Mon Sep 17 00:00:00 2001 From: "Malin J." Date: Fri, 4 Oct 2024 13:48:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9BCheck=20if=20block=20is=20empty=20o?= =?UTF-8?q?r=20default=20to=20array=20#2548?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/pageComponents/pageTemplates/News.tsx | 17 +++++++++-------- .../portableText/components/Footnotes.tsx | 5 ++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/web/pageComponents/pageTemplates/News.tsx b/web/pageComponents/pageTemplates/News.tsx index 9320e511e..ffe51dfea 100644 --- a/web/pageComponents/pageTemplates/News.tsx +++ b/web/pageComponents/pageTemplates/News.tsx @@ -136,6 +136,12 @@ const NewsPage = ({ data: news }: ArticleProps) => { const openGraphImages = getOpenGraphImages((openGraphImage?.asset ? openGraphImage : null) || heroImage?.image) /* appInsights.trackPageView({ name: slug, uri: fullUrl }) */ + + const formattedContent = content.map(block => ({ + ...block, + markDefs: block.markDefs || [], + })); + return ( <> { url: fullUrl, images: openGraphImages, }} - // twitter={{ - // handle: '@handle', - // site: '@site', - // cardType: 'summary_large_image', - // }} > { )} - {content && content.length > 0 && ( + {content && content.length > 0 && ( - )} + )}
diff --git a/web/pageComponents/shared/portableText/components/Footnotes.tsx b/web/pageComponents/shared/portableText/components/Footnotes.tsx index e1141ae5e..2f9aab074 100644 --- a/web/pageComponents/shared/portableText/components/Footnotes.tsx +++ b/web/pageComponents/shared/portableText/components/Footnotes.tsx @@ -14,9 +14,8 @@ function Footnotes({ blocks }: { blocks: PortableTextBlock[] }) { // make an array of the mark definitions of those blocks //@ts-ignore .reduce((acc, curr) => { - //TODO: look into more correct reduce - //@ts-ignore - return [...acc, ...curr?.markDefs] + const markDefs = Array.isArray(curr?.markDefs) ? curr.markDefs : [] + return [...acc, ...markDefs] }, []) // find all the footnote mark definitions //@ts-ignore