Skip to content

Commit abedcb4

Browse files
authored
Merge pull request #14989 from guardian/ih/hosted-content-type
Add initial type for hosted content to the DCR model
2 parents 1e65807 + f7819c9 commit abedcb4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { FEHostedContent } from '../frontend/feHostedContent';
2+
3+
type HostedContentType = 'article' | 'video' | 'gallery';
4+
5+
export type HostedContent = {
6+
frontendData: FEHostedContent;
7+
type: HostedContentType;
8+
};
9+
10+
export const enhanceHostedContentType = (
11+
data: FEHostedContent,
12+
): HostedContent => {
13+
let type: HostedContentType = 'article';
14+
15+
if (data.video) {
16+
type = 'video';
17+
} else if (data.images.length) {
18+
type = 'gallery';
19+
}
20+
21+
return {
22+
frontendData: data,
23+
type,
24+
};
25+
};

0 commit comments

Comments
 (0)