Skip to content

Commit

Permalink
Editions crossword handler
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielCliftonGuardian committed Nov 18, 2024
1 parent 4d2bc18 commit d621b92
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dotcom-rendering/scripts/json-schema/gen-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
getNewsletterPageSchema,
getTagPageSchema,
getBlockSchema,
getEditionsCrosswordSchema,
} = require('./get-schema');

const root = path.resolve(__dirname, '..', '..');
Expand All @@ -16,6 +17,7 @@ const frontSchema = getFrontSchema();
const tagPageSchema = getTagPageSchema();
const newsletterPageSchema = getNewsletterPageSchema();
const blockSchema = getBlockSchema();
const editionsCrosswordSchema = getEditionsCrosswordSchema();

fs.writeFile(
`${root}/src/model/article-schema.json`,
Expand Down Expand Up @@ -71,3 +73,14 @@ fs.writeFile(
}
},
);

fs.writeFile(
`${root}/src/model/editions-crossword-schema.json`,
editionsCrosswordSchema,
'utf8',
(err) => {
if (err) {
console.log(err);
}
},
);
10 changes: 10 additions & 0 deletions dotcom-rendering/scripts/json-schema/get-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const program = TJS.getProgramFromFiles(
path.resolve(`${root}/src/types/frontend.ts`),
path.resolve(`${root}/src/types/tagPage.ts`),
path.resolve(`${root}/src/types/newslettersPage.ts`),
path.resolve(`${root}/src/types/editionsCrossword.ts`),
],
{
skipLibCheck: true,
Expand Down Expand Up @@ -57,10 +58,19 @@ const getBlockSchema = () => {
);
};

const getEditionsCrosswordSchema = () => {
return JSON.stringify(
TJS.generateSchema(program, 'FEEditionsCrosswords', settings),
null,
4,
);
};

module.exports = {
getArticleSchema,
getFrontSchema,
getTagPageSchema,
getNewsletterPageSchema,
getBlockSchema,
getEditionsCrosswordSchema,
};
Loading

0 comments on commit d621b92

Please # to comment.