refactor(client): simplify page creation (#55720)

This commit is contained in:
Oliver Eyton-Williams
2024-08-13 17:36:00 +02:00
committed by GitHub
parent 90b2cfbfeb
commit 041a841995
15 changed files with 39 additions and 58 deletions
+14 -10
View File
@@ -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
}
});
};