From 5d0ce6babd7fbd460f0999b638a0f2712fef7dbc Mon Sep 17 00:00:00 2001 From: Ravi <7014230+arelra@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:55:29 +0000 Subject: [PATCH] Add additional blocks in enhanceArticleType Co-authored-by: Oliver Abrahams --- dotcom-rendering/src/model/enhanceBlocks.ts | 3 --- dotcom-rendering/src/types/article.ts | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dotcom-rendering/src/model/enhanceBlocks.ts b/dotcom-rendering/src/model/enhanceBlocks.ts index c37ec8e727..f2a4449307 100644 --- a/dotcom-rendering/src/model/enhanceBlocks.ts +++ b/dotcom-rendering/src/model/enhanceBlocks.ts @@ -31,7 +31,6 @@ type Options = { imagesForLightbox: ImageForLightbox[]; hasAffiliateLinksDisclaimer: boolean; audioArticleImage?: ImageBlockElement; - additionalBlocks?: Block[]; tags?: TagType[]; }; @@ -107,7 +106,6 @@ export const enhanceBlocks = ( options: Options, ): Block[] => { const additionalElements: FEElement[] = []; - const additionalBlocks: Block[] = options.additionalBlocks ?? []; if (options.audioArticleImage) { additionalElements.push(options.audioArticleImage); } @@ -120,6 +118,5 @@ export const enhanceBlocks = ( options, )([...block.elements, ...additionalElements]), })), - ...additionalBlocks, ]; }; diff --git a/dotcom-rendering/src/types/article.ts b/dotcom-rendering/src/types/article.ts index f115065f19..cb97c698f0 100644 --- a/dotcom-rendering/src/types/article.ts +++ b/dotcom-rendering/src/types/article.ts @@ -37,10 +37,6 @@ export const enhanceArticleType = ( ): Article => { const format = decideFormat(data.format); - const crosswordBlock = buildCrosswordBlock(data); - - const additionalBlocks = crosswordBlock ? [crosswordBlock] : []; - const imagesForLightbox = data.config.switches.lightbox ? buildLightboxImages(data.format, data.blocks, data.mainMediaElements) : []; @@ -51,10 +47,14 @@ export const enhanceArticleType = ( imagesForLightbox, hasAffiliateLinksDisclaimer: !!data.affiliateLinksDisclaimer, audioArticleImage: data.audioArticleImage, - additionalBlocks, tags: data.tags, }); + const crosswordBlock = buildCrosswordBlock(data); + const additionalBlocks = crosswordBlock ? [crosswordBlock] : []; + + const blocks = [...enhancedBlocks, ...additionalBlocks]; + const mainMediaElements = enhanceMainMedia( format, imagesForLightbox, @@ -67,7 +67,7 @@ export const enhanceArticleType = ( frontendData: { ...data, mainMediaElements, - blocks: enhancedBlocks, + blocks, pinnedPost: enhancePinnedPost( format, renderingTarget,