mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(client): simplify page creation (#55720)
This commit is contained in:
committed by
GitHub
parent
90b2cfbfeb
commit
041a841995
@@ -99,7 +99,7 @@ function getNextBlock(id, edges) {
|
||||
}
|
||||
|
||||
exports.createChallengePages = function (createPage) {
|
||||
return function ({ node: { challenge } }, index, allChallengeEdges) {
|
||||
return function ({ node }, index, allChallengeEdges) {
|
||||
const {
|
||||
dashedName,
|
||||
disableLoopProtectTests,
|
||||
@@ -112,7 +112,7 @@ exports.createChallengePages = function (createPage) {
|
||||
template,
|
||||
challengeType,
|
||||
id
|
||||
} = challenge;
|
||||
} = node.challenge;
|
||||
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
||||
// should remove one of them.
|
||||
|
||||
@@ -136,8 +136,11 @@ exports.createChallengePages = function (createPage) {
|
||||
prevChallengePath: getPrevChallengePath(index, allChallengeEdges),
|
||||
id
|
||||
},
|
||||
projectPreview: getProjectPreviewConfig(challenge, allChallengeEdges),
|
||||
slug
|
||||
projectPreview: getProjectPreviewConfig(
|
||||
node.challenge,
|
||||
allChallengeEdges
|
||||
),
|
||||
id: node.id
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -176,7 +179,8 @@ exports.createBlockIntroPages = function (createPage) {
|
||||
return function (edge) {
|
||||
const {
|
||||
fields: { slug },
|
||||
frontmatter: { block }
|
||||
frontmatter: { block },
|
||||
id
|
||||
} = edge.node;
|
||||
|
||||
createPage({
|
||||
@@ -184,7 +188,7 @@ exports.createBlockIntroPages = function (createPage) {
|
||||
component: intro,
|
||||
context: {
|
||||
block,
|
||||
slug
|
||||
id
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -194,7 +198,8 @@ exports.createSuperBlockIntroPages = function (createPage) {
|
||||
return function (edge) {
|
||||
const {
|
||||
fields: { slug },
|
||||
frontmatter: { superBlock, certification }
|
||||
frontmatter: { superBlock, certification },
|
||||
id
|
||||
} = edge.node;
|
||||
|
||||
if (!certification) {
|
||||
@@ -210,9 +215,8 @@ exports.createSuperBlockIntroPages = function (createPage) {
|
||||
path: slug,
|
||||
component: superBlockIntro,
|
||||
context: {
|
||||
certification,
|
||||
superBlock,
|
||||
slug
|
||||
id,
|
||||
superBlock
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user