Skip to content

Commit

Permalink
don’t override crossword format.design in enhancer
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed Dec 12, 2024
1 parent bb7ed69 commit 23342fb
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions dotcom-rendering/src/types/article.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { randomUUID } from 'node:crypto';
import {
ArticleDesign,
type ArticleFormat,
decideFormat,
} from '../lib/articleFormat';
import { isUndefined } from '@guardian/libs';
import { type ArticleFormat, decideFormat } from '../lib/articleFormat';
import type { ImageForAppsLightbox } from '../model/appsLightboxImages';
import { appsLightboxImages } from '../model/appsLightboxImages';
import { buildLightboxImages } from '../model/buildLightboxImages';
Expand Down Expand Up @@ -36,37 +32,37 @@ export type Article = {
};

export const enhanceCrossword = (article: Article): Article => {
if (article.frontendData.crossword) {
const element = {
_type: 'model.dotcomrendering.pageElements.CrosswordElement' as const,
crossword: article.frontendData.crossword,
};
return {
...article,
format: { ...article.format, design: ArticleDesign.Crossword },
frontendData: {
...article.frontendData,
blocks: [
{
id: randomUUID(),
elements: [element],
attributes: {
pinned: false,
keyEvent: false,
summary: false,
},
primaryDateLine:
article.frontendData.webPublicationDateDisplay,
secondaryDateLine:
article.frontendData
.webPublicationSecondaryDateDisplay,
},
],
},
};
if (isUndefined(article.frontendData.crossword)) {
throw new TypeError('article does not contain a crossword');
}

throw new TypeError('article did not contain a crossword');
const element = {
_type: 'model.dotcomrendering.pageElements.CrosswordElement' as const,
crossword: article.frontendData.crossword,
};

return {
...article,
format: { ...article.format },
frontendData: {
...article.frontendData,
blocks: [
{
id: article.frontendData.crossword.id,
elements: [element],
attributes: {
pinned: false,
keyEvent: false,
summary: false,
},
primaryDateLine:
article.frontendData.webPublicationDateDisplay,
secondaryDateLine:
article.frontendData.webPublicationSecondaryDateDisplay,
},
],
},
};
};

export const enhanceArticleType = (
Expand Down

0 comments on commit 23342fb

Please sign in to comment.