|
| 1 | +import type { FEHostedContent } from '../frontend/feHostedContent'; |
| 2 | +import { |
| 3 | + ArticleDesign, |
| 4 | + ArticleDisplay, |
| 5 | + ArticleSpecial, |
| 6 | +} from '../lib/articleFormat'; |
| 7 | +import { enhanceMainMedia } from '../model/enhanceBlocks'; |
| 8 | +import { enhanceCommercialProperties } from '../model/enhanceCommercialProperties'; |
| 9 | +import { enhanceStandfirst } from '../model/enhanceStandfirst'; |
1 | 10 | import type { Article } from './article'; |
2 | 11 |
|
3 | | -export type DCRHostedContent = Article; |
| 12 | +export type HostedContent = Article; |
| 13 | + |
| 14 | +export const enhanceHostedContent = (data: FEHostedContent): HostedContent => { |
| 15 | + // Temporarily hard coded |
| 16 | + const format = { |
| 17 | + display: ArticleDisplay.Standard, |
| 18 | + design: ArticleDesign.HostedArticle, |
| 19 | + theme: ArticleSpecial.Labs, |
| 20 | + }; |
| 21 | + |
| 22 | + const serverTime = Date.now(); |
| 23 | + |
| 24 | + /** @todo implement blocks */ |
| 25 | + // const enhancedBlocks = enhanceBlocks(data.blocks, format, { |
| 26 | + // renderingTarget, |
| 27 | + // promotedNewsletter: data.promotedNewsletter, |
| 28 | + // imagesForLightbox: [], |
| 29 | + // hasAffiliateLinksDisclaimer: !!data.affiliateLinksDisclaimer, |
| 30 | + // audioArticleImage: data.audioArticleImage, |
| 31 | + // tags: data.tags, |
| 32 | + // shouldHideAds: data.shouldHideAds, |
| 33 | + // pageId: data.pageId, |
| 34 | + // }); |
| 35 | + |
| 36 | + const mainMediaElements = enhanceMainMedia( |
| 37 | + format, |
| 38 | + [], //imagesForLightbox |
| 39 | + true, |
| 40 | + data.main, |
| 41 | + )(data.mainMediaElements); |
| 42 | + |
| 43 | + /** @ts-expect-error -- @todo fix this! */ |
| 44 | + return { |
| 45 | + design: format.design, |
| 46 | + display: format.display, |
| 47 | + theme: format.theme, |
| 48 | + serverTime, |
| 49 | + storyPackage: undefined, |
| 50 | + frontendData: { |
| 51 | + ...data, |
| 52 | + beaconURL: '', |
| 53 | + mainMediaElements, |
| 54 | + blocks: [], |
| 55 | + standfirst: enhanceStandfirst(data.standfirst), |
| 56 | + commercialProperties: enhanceCommercialProperties( |
| 57 | + data.commercialProperties, |
| 58 | + ), |
| 59 | + /** |
| 60 | + * This function needs to run at a higher level to most other enhancers |
| 61 | + * because it needs both mainMediaElements and blocks in scope |
| 62 | + * @todo implement for Hosted Content pages |
| 63 | + */ |
| 64 | + imagesForLightbox: [], |
| 65 | + /** @todo implement for Hosted Content pages */ |
| 66 | + imagesForAppsLightbox: [], |
| 67 | + }, |
| 68 | + }; |
| 69 | +}; |
0 commit comments