diff --git a/client/src/templates/Challenges/components/Challenge-Description.js b/client/src/templates/Challenges/components/Challenge-Description.js index 0d328d7c76..6df5e2cfff 100644 --- a/client/src/templates/Challenges/components/Challenge-Description.js +++ b/client/src/templates/Challenges/components/Challenge-Description.js @@ -9,17 +9,11 @@ const propTypes = { section: PropTypes.string }; -function emptyInstruction(instructions) { - return /^\s*<\/section>$/.test( - instructions - ); -} - function ChallengeDescription({ description, instructions, section }) { return (
- {!emptyInstruction(instructions) && ( + {instructions && (
diff --git a/curriculum/schema/challengeSchema.js b/curriculum/schema/challengeSchema.js index 53d25622b6..ee39562edb 100644 --- a/curriculum/schema/challengeSchema.js +++ b/curriculum/schema/challengeSchema.js @@ -1,6 +1,8 @@ const Joi = require('joi'); Joi.objectId = require('joi-objectid')(Joi); +const { challengeTypes } = require('../../client/utils/challengeTypes'); + function getSchemaForLang(lang) { let schema = Joi.object().keys({ block: Joi.string(), @@ -12,7 +14,11 @@ function getSchemaForLang(lang) { .required(), checksum: Joi.number(), dashedName: Joi.string(), - description: Joi.string().required(), + description: Joi.when('challengeType', { + is: challengeTypes.step, + then: Joi.string().allow(''), + otherwise: Joi.string().required() + }), fileName: Joi.string(), files: Joi.array().items( Joi.object().keys({ @@ -37,7 +43,7 @@ function getSchemaForLang(lang) { videoUrl: Joi.string().allow(''), helpRoom: Joi.string(), id: Joi.objectId().required(), - instructions: Joi.string().required(), + instructions: Joi.string().allow(''), isBeta: Joi.bool(), isComingSoon: Joi.bool(), isLocked: Joi.bool(), diff --git a/tools/challenge-md-parser/text-to-data.js b/tools/challenge-md-parser/text-to-data.js index 638b5835a7..6f91a13afa 100644 --- a/tools/challenge-md-parser/text-to-data.js +++ b/tools/challenge-md-parser/text-to-data.js @@ -62,7 +62,12 @@ function textToData(sectionIds) { } } }); - const textArray = toHTML({ ...node, children: newChildren }); + const hasData = newChildren.some( + node => node.type !== 'text' || !/^\s*$/.test(node.value) + ); + const textArray = hasData + ? toHTML({ ...node, children: newChildren }) + : ''; file.data = { ...file.data, [sectionId]: textArray