refactor: stop spreading challenge over the node (#44499)
* refactor: stop spreading challenge over the node Instead of creating a Gatsby node with id of challenge.id, we create a single node field that has all the challenge data. While this makes the GraphQL queries more verbose, it means we're free to create multiple nodes with the same challenge.id. * test: update time-line test for new GQL schema * test: update mocks with new GQL schema
This commit is contained in:
committed by
GitHub
parent
755f27093c
commit
3b560deab6
@ -45,12 +45,12 @@ const views = {
|
||||
|
||||
function getNextChallengePath(_node, index, nodeArray) {
|
||||
const next = nodeArray[index + 1];
|
||||
return next ? next.node.fields.slug : '/learn';
|
||||
return next ? next.node.challenge.fields.slug : '/learn';
|
||||
}
|
||||
|
||||
function getPrevChallengePath(_node, index, nodeArray) {
|
||||
const prev = nodeArray[index - 1];
|
||||
return prev ? prev.node.fields.slug : '/learn';
|
||||
return prev ? prev.node.challenge.fields.slug : '/learn';
|
||||
}
|
||||
|
||||
function getTemplateComponent(challengeType) {
|
||||
@ -58,7 +58,7 @@ function getTemplateComponent(challengeType) {
|
||||
}
|
||||
|
||||
exports.createChallengePages = function (createPage) {
|
||||
return function ({ node: challenge }, index, allChallengeEdges) {
|
||||
return function ({ node: { challenge } }, index, allChallengeEdges) {
|
||||
const {
|
||||
superBlock,
|
||||
block,
|
||||
@ -103,8 +103,8 @@ function getProjectPreviewConfig(challenge, allChallengeEdges) {
|
||||
const { block, challengeOrder, usesMultifileEditor } = challenge;
|
||||
|
||||
const challengesInBlock = allChallengeEdges
|
||||
.filter(({ node }) => node.block === block)
|
||||
.map(({ node }) => node);
|
||||
.filter(({ node: { challenge } }) => challenge.block === block)
|
||||
.map(({ node: { challenge } }) => challenge);
|
||||
const lastChallenge = challengesInBlock[challengesInBlock.length - 1];
|
||||
const solutionToLastChallenge = sortChallengeFiles(
|
||||
lastChallenge.solutions[0] ?? []
|
||||
|
Reference in New Issue
Block a user