Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 52 additions & 46 deletions dotcom-rendering/src/frontend/feArticle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type CrosswordProps } from '@guardian/react-crossword';
import { literal, object, type Output, union } from 'valibot';
import type { EditionId } from '../lib/edition';
import type { FEArticleBadgeType } from '../types/badge';
import type { Block } from '../types/blocks';
Expand Down Expand Up @@ -135,65 +136,70 @@ type PageType = {
isSensitive: boolean;
};

type ThemePillar =
| 'NewsPillar'
| 'OpinionPillar'
| 'SportPillar'
| 'CulturePillar'
| 'LifestylePillar';

type ThemeSpecial = 'SpecialReportTheme' | 'Labs' | 'SpecialReportAltTheme';
type FETheme = ThemePillar | ThemeSpecial;
const FEThemeSchema = union([
literal('NewsPillar'),
literal('OpinionPillar'),
literal('SportPillar'),
literal('CulturePillar'),
literal('LifestylePillar'),
literal('SpecialReportTheme'),
literal('Labs'),
literal('SpecialReportAltTheme'),
]);

/**
* FEDesign is what frontend gives (originating in the capi scala client) us on the Format field
* https://github.com/guardian/content-api-scala-client/blob/master/client/src/main/scala/com.gu.contentapi.client/utils/format/Design.scala
*/
type FEDesign =
| 'ArticleDesign'
| 'PictureDesign'
| 'GalleryDesign'
| 'AudioDesign'
| 'VideoDesign'
| 'CrosswordDesign'
| 'ReviewDesign'
| 'AnalysisDesign'
| 'CommentDesign'
| 'ExplainerDesign'
| 'LetterDesign'
| 'FeatureDesign'
| 'LiveBlogDesign'
| 'DeadBlogDesign'
| 'RecipeDesign'
| 'MatchReportDesign'
| 'InterviewDesign'
| 'EditorialDesign'
| 'QuizDesign'
| 'InteractiveDesign'
| 'PhotoEssayDesign'
| 'ObituaryDesign'
| 'FullPageInteractiveDesign'
| 'NewsletterSignupDesign'
| 'TimelineDesign'
| 'ProfileDesign';
const FEDesignSchema = union([
literal('ArticleDesign'),
literal('PictureDesign'),
literal('GalleryDesign'),
literal('AudioDesign'),
literal('VideoDesign'),
literal('CrosswordDesign'),
literal('ReviewDesign'),
literal('AnalysisDesign'),
literal('CommentDesign'),
literal('ExplainerDesign'),
literal('LetterDesign'),
literal('FeatureDesign'),
literal('LiveBlogDesign'),
literal('DeadBlogDesign'),
literal('RecipeDesign'),
literal('MatchReportDesign'),
literal('InterviewDesign'),
literal('EditorialDesign'),
literal('QuizDesign'),
literal('InteractiveDesign'),
literal('PhotoEssayDesign'),
literal('ObituaryDesign'),
literal('FullPageInteractiveDesign'),
literal('NewsletterSignupDesign'),
literal('TimelineDesign'),
literal('ProfileDesign'),
]);

/** FEDisplay is the display information passed through from frontend (originating in the capi scala client) and dictates the display style of the content e.g. Immersive
https://github.com/guardian/content-api-scala-client/blob/master/client/src/main/scala/com.gu.contentapi.client/utils/format/Display.scala */
type FEDisplay =
| 'StandardDisplay'
| 'ImmersiveDisplay'
| 'ShowcaseDisplay'
| 'NumberedListDisplay';
const FEDisplaySchema = union([
literal('StandardDisplay'),
literal('ImmersiveDisplay'),
literal('ShowcaseDisplay'),
literal('NumberedListDisplay'),
]);

/**
* FEFormat is the stringified version of Format passed through from Frontend.
* It gets converted to the `@guardian/libs` format on platform
*/
export type FEFormat = {
design: FEDesign;
theme: FETheme;
display: FEDisplay;
};
export type FEFormat = Output<typeof FEFormatSchema>;

export const FEFormatSchema = object({
design: FEDesignSchema,
theme: FEThemeSchema,
display: FEDisplaySchema,
});

export type FEStoryPackage = {
heading: string;
Expand Down
847 changes: 363 additions & 484 deletions dotcom-rendering/src/frontend/schemas/feArticle.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dotcom-rendering/src/frontend/schemas/feCricketMatchPage.json
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@
"adUnit": {
"type": "string"
},
"pillar": {
"type": "string"
},
"avatarApiUrl": {
"type": "string"
},
Expand Down Expand Up @@ -598,9 +601,6 @@
"assetsPath": {
"type": "string"
},
"pillar": {
"type": "string"
},
"commercialBundleUrl": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@
"adUnit": {
"type": "string"
},
"pillar": {
"type": "string"
},
"avatarApiUrl": {
"type": "string"
},
Expand Down Expand Up @@ -445,9 +448,6 @@
"assetsPath": {
"type": "string"
},
"pillar": {
"type": "string"
},
"commercialBundleUrl": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@
"adUnit": {
"type": "string"
},
"pillar": {
"type": "string"
},
"avatarApiUrl": {
"type": "string"
},
Expand Down Expand Up @@ -615,9 +618,6 @@
"assetsPath": {
"type": "string"
},
"pillar": {
"type": "string"
},
"commercialBundleUrl": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@
"adUnit": {
"type": "string"
},
"pillar": {
"type": "string"
},
"avatarApiUrl": {
"type": "string"
},
Expand Down Expand Up @@ -654,9 +657,6 @@
"assetsPath": {
"type": "string"
},
"pillar": {
"type": "string"
},
"commercialBundleUrl": {
"type": "string"
},
Expand Down
Loading
Loading