mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: add superblock intro to curriculum data API (#47161)
* feat: add superblock intro to curriculum data API * fix: type correlation intro * fix: add key to Joi schema
This commit is contained in:
@@ -11,6 +11,7 @@ interface IntroProps extends CurriculumProps {
|
||||
}
|
||||
|
||||
interface CurriculumProps {
|
||||
intro: string[];
|
||||
blocks: Record<string, Block>;
|
||||
}
|
||||
|
||||
@@ -73,6 +74,8 @@ export function buildExtCurriculumData(
|
||||
if (blockNames.length === 0) continue;
|
||||
|
||||
superBlock[superBlockKey] = <CurriculumProps>{};
|
||||
superBlock[superBlockKey]['intro'] =
|
||||
getSuperBlockDescription(superBlockKey);
|
||||
superBlock[superBlockKey]['blocks'] = {};
|
||||
|
||||
for (let j = 0; j < blockNames.length; j++) {
|
||||
@@ -104,6 +107,13 @@ export function buildExtCurriculumData(
|
||||
return intros[superBlockKeys]['blocks'][blockKey]['intro'];
|
||||
}
|
||||
|
||||
function getSuperBlockDescription(superBlockKey: SuperBlocks): string[] {
|
||||
const superBlockIntro = JSON.parse(
|
||||
readFileSync(blockIntroPath, 'utf-8')
|
||||
) as Intro;
|
||||
return superBlockIntro[superBlockKey]['intro'];
|
||||
}
|
||||
|
||||
function getSuperBlockTitle(superBlock: SuperBlocks): string {
|
||||
const superBlocks = JSON.parse(
|
||||
readFileSync(blockIntroPath, 'utf-8')
|
||||
|
||||
@@ -19,6 +19,7 @@ const blockSchema = Joi.object({}).keys({
|
||||
});
|
||||
|
||||
const subSchema = Joi.object({}).keys({
|
||||
intro: Joi.array(),
|
||||
blocks: Joi.object({}).pattern(Joi.string(), Joi.object().concat(blockSchema))
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user