feat: add data for preview to challengeMeta

This commit is contained in:
Oliver Eyton-Williams
2021-10-19 16:10:21 +02:00
committed by moT01
parent a0d3f22dfc
commit e04ac51147
2 changed files with 17 additions and 5 deletions

View File

@ -87,6 +87,10 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
src src
} }
challengeOrder challengeOrder
solutions {
contents
ext
}
superBlock superBlock
superOrder superOrder
template template

View File

@ -57,7 +57,7 @@ function getTemplateComponent(challengeType) {
} }
exports.createChallengePages = function (createPage) { exports.createChallengePages = function (createPage) {
return function ({ node }, index, thisArray) { return function ({ node }, index, allChallenges) {
const { const {
superBlock, superBlock,
block, block,
@ -65,11 +65,17 @@ exports.createChallengePages = function (createPage) {
required = [], required = [],
template, template,
challengeType, challengeType,
id id,
challengeOrder
} = node; } = node;
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we // TODO: challengeType === 7 and isPrivate are the same, right? If so, we
// should remove one of them. // should remove one of them.
const challengesInBlock = allChallenges.filter(
({ node }) => node.block === block
);
const allSolutionsToLastChallenge =
challengesInBlock[challengesInBlock.length - 1].node.solutions;
createPage({ createPage({
path: slug, path: slug,
component: getTemplateComponent(challengeType), component: getTemplateComponent(challengeType),
@ -79,9 +85,11 @@ exports.createChallengePages = function (createPage) {
block, block,
template, template,
required, required,
nextChallengePath: getNextChallengePath(node, index, thisArray), nextChallengePath: getNextChallengePath(node, index, allChallenges),
prevChallengePath: getPrevChallengePath(node, index, thisArray), prevChallengePath: getPrevChallengePath(node, index, allChallenges),
id id,
isFirstChallengeInBlock: challengeOrder === 0,
solutionToLastChallenge: allSolutionsToLastChallenge[0]
}, },
slug slug
} }