diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 173c7e2a73..753cc90e97 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -87,6 +87,10 @@ exports.createPages = function createPages({ graphql, actions, reporter }) { src } challengeOrder + solutions { + contents + ext + } superBlock superOrder template diff --git a/client/utils/gatsby/challenge-page-creator.js b/client/utils/gatsby/challenge-page-creator.js index 67532af2c3..aa1325fd7f 100644 --- a/client/utils/gatsby/challenge-page-creator.js +++ b/client/utils/gatsby/challenge-page-creator.js @@ -57,7 +57,7 @@ function getTemplateComponent(challengeType) { } exports.createChallengePages = function (createPage) { - return function ({ node }, index, thisArray) { + return function ({ node }, index, allChallenges) { const { superBlock, block, @@ -65,11 +65,17 @@ exports.createChallengePages = function (createPage) { required = [], template, challengeType, - id + id, + challengeOrder } = node; // TODO: challengeType === 7 and isPrivate are the same, right? If so, we // should remove one of them. + const challengesInBlock = allChallenges.filter( + ({ node }) => node.block === block + ); + const allSolutionsToLastChallenge = + challengesInBlock[challengesInBlock.length - 1].node.solutions; createPage({ path: slug, component: getTemplateComponent(challengeType), @@ -79,9 +85,11 @@ exports.createChallengePages = function (createPage) { block, template, required, - nextChallengePath: getNextChallengePath(node, index, thisArray), - prevChallengePath: getPrevChallengePath(node, index, thisArray), - id + nextChallengePath: getNextChallengePath(node, index, allChallenges), + prevChallengePath: getPrevChallengePath(node, index, allChallenges), + id, + isFirstChallengeInBlock: challengeOrder === 0, + solutionToLastChallenge: allSolutionsToLastChallenge[0] }, slug }