Skip to content

Commit

Permalink
šŸ›Check if block is empty or default to array #2548
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia committed Oct 4, 2024
1 parent ef146ee commit cca5235
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 9 additions & 8 deletions web/pageComponents/pageTemplates/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<NextSeo
Expand All @@ -152,11 +158,6 @@ const NewsPage = ({ data: news }: ArticleProps) => {
url: fullUrl,
images: openGraphImages,
}}
// twitter={{
// handle: '@handle',
// site: '@site',
// cardType: 'summary_large_image',
// }}
></NextSeo>
<NewsArticleJsonLd
url={fullUrl}
Expand Down Expand Up @@ -210,14 +211,14 @@ const NewsPage = ({ data: news }: ArticleProps) => {
</LeadParagraph>
)}

{content && content.length > 0 && (
{content && content.length > 0 && (
<Blocks
value={content}
value={formattedContent}
proseClassName="prose-article"
className="p-0 max-w-viewport mx-auto"
includeFootnotes
/>
)}
)}
<div className="mt-8 mb-2 px-layout-lg max-w-viewport mx-auto">
<Footnotes blocks={[...ingress, ...content]} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cca5235

Please sign in to comment.