Skip to content

Commit aa2c34c

Browse files
Fixing remaining issues
1 parent 503658c commit aa2c34c

File tree

6 files changed

+37
-150
lines changed

6 files changed

+37
-150
lines changed

dotcom-rendering/src/components/LoopVideoInArticle.importable.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ type LoopVideoInArticleProps = {
2222
posterImage: string;
2323
uniqueId: string;
2424
width: number;
25-
subtitleSource?: string;
26-
subtitleSize?: string;
2725
};
2826

2927
// The looping video player types its `sources` attribute as `Sources`
@@ -38,14 +36,11 @@ const convertAssetsToSources = (assets: VideoAssets[]): Source[] => {
3836
});
3937
};
4038

41-
const convertSubtitleSize = (val?: string): SubtitleSize => {
42-
if (val == null) {
43-
return 'small' as SubtitleSize;
44-
}
45-
if (['small', 'medium', 'large'].includes(val)) {
46-
return val as SubtitleSize;
47-
}
48-
return 'small' as SubtitleSize;
39+
const getSubtitleAsset = (assets: VideoAssets[]) => {
40+
// Get the first subtitle asset from assets with a mimetype of 'text/vtt'
41+
42+
const candidate = assets.find((asset) => asset.mimeType === 'text/vtt');
43+
return candidate?.url;
4944
};
5045

5146
export const LoopVideoInArticle = ({
@@ -62,8 +57,6 @@ export const LoopVideoInArticle = ({
6257
isMainMedia,
6358
linkTo,
6459
posterImage,
65-
subtitleSize,
66-
subtitleSource,
6760
uniqueId,
6861
width = 500,
6962
}: LoopVideoInArticleProps) => {
@@ -80,8 +73,8 @@ export const LoopVideoInArticle = ({
8073
linkTo={linkTo}
8174
posterImage={posterImage}
8275
sources={convertAssetsToSources(assets)}
83-
subtitleSize={convertSubtitleSize(subtitleSize)}
84-
subtitleSource={subtitleSource}
76+
subtitleSize={'small' as SubtitleSize}
77+
subtitleSource={getSubtitleAsset(assets)}
8578
uniqueId={uniqueId}
8679
width={width}
8780
/>

dotcom-rendering/src/components/VideoAtom.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import type { ArticleFormat } from '../lib/articleFormat';
2-
import type { VideoAssets } from '../types/content';
32
import { Caption } from './Caption';
43
import { MaintainAspectRatio } from './MaintainAspectRatio';
54

6-
// type AssetType = {
7-
// url: string;
8-
// mimeType?: string;
9-
// };
5+
type AssetType = {
6+
url: string;
7+
mimeType?: string;
8+
};
109

1110
interface Props {
1211
format: ArticleFormat;
13-
assets: VideoAssets[];
12+
assets: AssetType[];
1413
isMainMedia: boolean;
1514
poster?: string;
1615
caption?: string;

dotcom-rendering/src/frontend/schemas/feArticle.json

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,6 @@
680680
{
681681
"$ref": "#/definitions/ListBlockElement"
682682
},
683-
{
684-
"$ref": "#/definitions/LoopVideoInArticleElement"
685-
},
686683
{
687684
"$ref": "#/definitions/MapBlockElement"
688685
},
@@ -2607,57 +2604,6 @@
26072604
"elements"
26082605
]
26092606
},
2610-
"LoopVideoInArticleElement": {
2611-
"type": "object",
2612-
"properties": {
2613-
"_type": {
2614-
"type": "string",
2615-
"const": "model.dotcomrendering.pageElements.MediaAtomBlockElement"
2616-
},
2617-
"elementId": {
2618-
"type": "string"
2619-
},
2620-
"id": {
2621-
"type": "string"
2622-
},
2623-
"assets": {
2624-
"type": "array",
2625-
"items": {
2626-
"$ref": "#/definitions/VideoAssets"
2627-
}
2628-
},
2629-
"posterImage": {
2630-
"type": "array",
2631-
"items": {
2632-
"type": "object",
2633-
"properties": {
2634-
"url": {
2635-
"type": "string"
2636-
},
2637-
"width": {
2638-
"type": "number"
2639-
}
2640-
},
2641-
"required": [
2642-
"url",
2643-
"width"
2644-
]
2645-
}
2646-
},
2647-
"title": {
2648-
"type": "string"
2649-
},
2650-
"duration": {
2651-
"type": "number"
2652-
}
2653-
},
2654-
"required": [
2655-
"_type",
2656-
"assets",
2657-
"elementId",
2658-
"id"
2659-
]
2660-
},
26612607
"MapBlockElement": {
26622608
"type": "object",
26632609
"properties": {
@@ -2752,6 +2698,9 @@
27522698
},
27532699
"duration": {
27542700
"type": "number"
2701+
},
2702+
"videoPlayerFormat": {
2703+
"type": "string"
27552704
}
27562705
},
27572706
"required": [

dotcom-rendering/src/lib/renderElement.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ export const renderElement = ({
519519
<LoopVideoInArticle
520520
assets={element.assets}
521521
atomId={element.id}
522-
uniqueId={`${Math.random()}`}
522+
uniqueId={element.id}
523523
height={400}
524524
width={500}
525525
posterImage={
@@ -536,8 +536,6 @@ export const renderElement = ({
536536
format={format}
537537
caption={element.title}
538538
isMainMedia={isMainMedia}
539-
subtitleSize={element.subtitleSize}
540-
subtitleSource={element.subtitleSource}
541539
/>
542540
</Island>
543541
)}

dotcom-rendering/src/model/block-schema.json

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@
168168
{
169169
"$ref": "#/definitions/ListBlockElement"
170170
},
171-
{
172-
"$ref": "#/definitions/LoopVideoInArticleElement"
173-
},
174171
{
175172
"$ref": "#/definitions/MapBlockElement"
176173
},
@@ -2095,57 +2092,6 @@
20952092
"elements"
20962093
]
20972094
},
2098-
"LoopVideoInArticleElement": {
2099-
"type": "object",
2100-
"properties": {
2101-
"_type": {
2102-
"type": "string",
2103-
"const": "model.dotcomrendering.pageElements.MediaAtomBlockElement"
2104-
},
2105-
"elementId": {
2106-
"type": "string"
2107-
},
2108-
"id": {
2109-
"type": "string"
2110-
},
2111-
"assets": {
2112-
"type": "array",
2113-
"items": {
2114-
"$ref": "#/definitions/VideoAssets"
2115-
}
2116-
},
2117-
"posterImage": {
2118-
"type": "array",
2119-
"items": {
2120-
"type": "object",
2121-
"properties": {
2122-
"url": {
2123-
"type": "string"
2124-
},
2125-
"width": {
2126-
"type": "number"
2127-
}
2128-
},
2129-
"required": [
2130-
"url",
2131-
"width"
2132-
]
2133-
}
2134-
},
2135-
"title": {
2136-
"type": "string"
2137-
},
2138-
"duration": {
2139-
"type": "number"
2140-
}
2141-
},
2142-
"required": [
2143-
"_type",
2144-
"assets",
2145-
"elementId",
2146-
"id"
2147-
]
2148-
},
21492095
"MapBlockElement": {
21502096
"type": "object",
21512097
"properties": {
@@ -2240,6 +2186,9 @@
22402186
},
22412187
"duration": {
22422188
"type": "number"
2189+
},
2190+
"videoPlayerFormat": {
2191+
"type": "string"
22432192
}
22442193
},
22452194
"required": [

dotcom-rendering/src/types/content.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -411,21 +411,21 @@ export interface ListBlockElement {
411411
elementId: string;
412412
}
413413

414-
interface LoopVideoInArticleElement {
415-
_type: 'model.dotcomrendering.pageElements.MediaAtomBlockElement';
416-
elementId: string;
417-
id: string;
418-
assets: VideoAssets[];
419-
posterImage?: {
420-
url: string;
421-
width: number;
422-
}[];
423-
title?: string;
424-
duration?: number;
425-
videoPlayerFormat?: string;
426-
subtitleSize?: string;
427-
subtitleSource?: string;
428-
}
414+
// interface LoopVideoInArticleElement {
415+
// _type: 'model.dotcomrendering.pageElements.MediaAtomBlockElement';
416+
// elementId: string;
417+
// id: string;
418+
// assets: VideoAssets[];
419+
// posterImage?: {
420+
// url: string;
421+
// width: number;
422+
// }[];
423+
// title?: string;
424+
// duration?: number;
425+
// videoPlayerFormat?: string;
426+
// subtitleSize?: string;
427+
// subtitleSource?: string;
428+
// }
429429

430430
export interface MapBlockElement extends ThirdPartyEmbeddedContent {
431431
_type: 'model.dotcomrendering.pageElements.MapBlockElement';
@@ -451,8 +451,8 @@ interface MediaAtomBlockElement {
451451
title?: string;
452452
duration?: number;
453453
videoPlayerFormat?: string;
454-
subtitleSize?: string;
455-
subtitleSource?: string;
454+
// subtitleSize?: string;
455+
// subtitleSource?: string;
456456
}
457457

458458
export interface MultiImageBlockElement {
@@ -838,7 +838,6 @@ export type FEElement =
838838
| KeyTakeawaysBlockElement
839839
| LinkBlockElement
840840
| ListBlockElement
841-
| LoopVideoInArticleElement
842841
| MapBlockElement
843842
| MediaAtomBlockElement
844843
| MiniProfilesBlockElement
@@ -960,7 +959,7 @@ export interface Image {
960959
}
961960

962961
export interface VideoAssets {
963-
url?: string;
962+
url: string;
964963
mimeType?: string;
965964
fields?: {
966965
source?: string;

0 commit comments

Comments
 (0)