Skip to content

Commit

Permalink
✏️ Rewrite block groq #2548 (#2549)
Browse files Browse the repository at this point in the history
* ✏️ Rewrite block groq #2548

* 🐛Check if block is empty or default to array #2548
  • Loading branch information
millianapia authored Oct 9, 2024
1 parent 7ed47aa commit 82d0bc7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions web/lib/queries/common/blockEditorMarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const referenceFields = /* groq */ `
`

const markDefs = /* groq */ `
"markDefs": markDefs[]{
...,
_type == "internalLink" => {
"internalLink": select(
linkToOtherLanguage == true =>
referenceToOtherLanguange->${referenceFields},
markDefs[]{
...,
_type == "internalLink" => {
"internalLink": select(
linkToOtherLanguage == true =>
referenceToOtherLanguange->${referenceFields},
reference->${referenceFields},
)
},
}
}
`

export default markDefs
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 82d0bc7

Please sign in to comment.