feat: use growthbook to determine next and previous challenges (#57435)

This commit is contained in:
Oliver Eyton-Williams
2024-12-12 18:27:41 +01:00
committed by GitHub
parent 3e0b2b914c
commit 827b9e3ecd
14 changed files with 237 additions and 37 deletions
+15 -13
View File
@@ -72,21 +72,19 @@ function getIsFirstStepInBlock(id, edges) {
return previous.node.challenge.block !== current.node.challenge.block;
}
function getNextChallengePath(id, edges) {
const next = edges[id + 1];
return next ? next.node.challenge.fields.slug : null;
}
function getPrevChallengePath(id, edges) {
const prev = edges[id - 1];
return prev ? prev.node.challenge.fields.slug : null;
}
function getTemplateComponent(challengeType) {
return views[viewTypes[challengeType]];
}
exports.createChallengePages = function (createPage) {
exports.createChallengePages = function (
createPage,
{
idToNextPathCurrentCurriculum,
idToPrevPathCurrentCurriculum,
idToNextPathNextCurriculum,
idToPrevPathNextCurriculum
}
) {
return function ({ node }, index, allChallengeEdges) {
const {
dashedName,
@@ -121,10 +119,14 @@ exports.createChallengePages = function (createPage) {
template,
required,
isLastChallengeInBlock: isLastChallengeInBlock,
nextChallengePath: getNextChallengePath(index, allChallengeEdges),
prevChallengePath: getPrevChallengePath(index, allChallengeEdges),
nextChallengePath: idToNextPathCurrentCurriculum[node.id],
prevChallengePath: idToPrevPathCurrentCurriculum[node.id],
id
},
nextCurriculumPaths: {
nextChallengePath: idToNextPathNextCurriculum[node.id],
prevChallengePath: idToPrevPathNextCurriculum[node.id]
},
projectPreview: getProjectPreviewConfig(
node.challenge,
allChallengeEdges
+1 -1
View File
@@ -3,7 +3,7 @@
* but the link of the page isn't rendered on the screen.
* For more details, see https://github.com/freeCodeCamp/freeCodeCamp/pull/55472.
*/
export const preloadPage = (path: string | null) => {
export const preloadPage = (path?: string) => {
if (!window.___loader || !path) return;
window.___loader.hovering(path);