Skip to content

Commit

Permalink
Add additional blocks in enhanceArticleType
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Abrahams <[email protected]>
  • Loading branch information
arelra and oliverabrahams committed Jan 16, 2025
1 parent 12d7460 commit 5d0ce6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 0 additions & 3 deletions dotcom-rendering/src/model/enhanceBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Options = {
imagesForLightbox: ImageForLightbox[];
hasAffiliateLinksDisclaimer: boolean;
audioArticleImage?: ImageBlockElement;
additionalBlocks?: Block[];
tags?: TagType[];
};

Expand Down Expand Up @@ -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);
}
Expand All @@ -120,6 +118,5 @@ export const enhanceBlocks = (
options,
)([...block.elements, ...additionalElements]),
})),
...additionalBlocks,
];
};
12 changes: 6 additions & 6 deletions dotcom-rendering/src/types/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
: [];
Expand All @@ -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,
Expand All @@ -67,7 +67,7 @@ export const enhanceArticleType = (
frontendData: {
...data,
mainMediaElements,
blocks: enhancedBlocks,
blocks,
pinnedPost: enhancePinnedPost(
format,
renderingTarget,
Expand Down

0 comments on commit 5d0ce6b

Please sign in to comment.