MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / BlockCreator

Class BlockCreator

curriculum/src/build-superblock.ts:265–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263 return addMetaToChallenge(fixChallengeProperties(challenge), meta);
264}
265export class BlockCreator {
266 /**
267 * @param {object} options - Options object
268 * @param {string} options.blockContentDir - Directory containing block content files
269 * @param {string} options.i18nBlockContentDir - Directory containing i18n block content files
270 * @param {string} options.lang - Language code for the block content
271 * @param {object} options.commentTranslations - Translations for comments in challenges
272 * @constructor
273 * @description Initializes the BlockCreator with directories for block content and structure.
274 * This class is responsible for reading block directories, parsing challenges, and validating them
275 * against the meta information.
276 */
277
278 blockContentDir: string;
279 i18nBlockContentDir: string;
280 lang: string;
281 commentTranslations: CommentDictionary;
282 skipValidation: boolean | undefined;
283
284 constructor({
285 blockContentDir,
286 i18nBlockContentDir,
287 lang,
288 commentTranslations,
289 skipValidation
290 }: {
291 blockContentDir: string;
292 i18nBlockContentDir: string;
293 lang: string;
294 commentTranslations: CommentDictionary;
295 skipValidation?: boolean;
296 }) {
297 this.blockContentDir = blockContentDir;
298 this.i18nBlockContentDir = i18nBlockContentDir;
299 this.lang = lang;
300 this.commentTranslations = commentTranslations;
301 this.skipValidation = skipValidation;
302 }
303
304 /**
305 * Creates a challenge from a markdown file
306 * @param {object} options - Options object
307 * @param {string} options.filename - Name of the challenge file
308 * @param {string} options.block - Name of the block
309 * @param {object} options.meta - Meta information for the block
310 * @param {boolean} options.isAudited - Whether the block is audited for i18n
311 * @param {Function} parser - Parser function to use (defaults to parseMD)
312 * @returns {Promise<object>} The finalized challenge object
313 */
314 async createChallenge(
315 {
316 filename,
317 block,
318 meta,
319 isAudited
320 }: { filename: string; block: string; meta: Meta; isAudited: boolean },
321 parser = parseMD
322 ) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected