mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: use growthbook to determine next and previous challenges (#57435)
This commit is contained in:
committed by
GitHub
parent
3e0b2b914c
commit
827b9e3ecd
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user