* feat: use legacy flag chore: reorder challenges fix: linter revert: server change feat: unblock new editor fix: proper order fix: 0-based order fix: broke the order feat: move tribute certification to its own block feat: split the old projects block into 4 fix: put all blocks in order chore: add intro text refactor: use block, not blockName in query fix: project progress indicator * fix: reorder new challenges/certs * fix: reorder legacy challenges * fix: reintroduce legacy certs * feat: add showNewCurriculum flag to env * chore: forgot sample.env * feat: use feature flag for display * fix: rename meta + dirs to match new blocks * fix: add new blocks to help-category-map * fix: update completion-modal for new GQL schema * test: duplicate title/id errors -> warnings * fix: update completion-modal to new GQL schema Mk2 * chore: re-order metas (again) * fix: revert super-block-intro changes The intro needs to show both legacy and new content. We need to decide which pages are created, rather than than what a page shows when rendered. * feat: move upcoming curriculum into own superblock * fix: handle one certification with two superBlocks * fix: remove duplicated intros * fix: remove duplicate projects from /settings * fix: drop 'two' from Responsive Web Design Two * chore: rename slug suffix from two to v2 * feat: control display of new curriculum * feat: control project paths shown on /settings * fix: use new project order for /settings This does mean that /settings will change before the release, but I don't think it's serious. All the projects are there, just not in the legacy order. * fix: claim/show cert button * chore: remove isLegacy Since we have legacy superblocks, we don't currently need individual blocks to be legacy * test: fix utils.test * fix: verifyCanClaim needs certification If Shaun removes the cert claim cards, maybe we can remove this entirely * fix: add hasEditableBoundaries flags where needed * chore: remove isUpcomingChange * chore: v2 -> 22 Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
180 lines
4.5 KiB
JavaScript
180 lines
4.5 KiB
JavaScript
const path = require('path');
|
|
const { createPoly } = require('../../../utils/polyvinyl');
|
|
const { dasherize } = require('../../../utils/slugs');
|
|
const { sortChallengeFiles } = require('../../../utils/sort-challengefiles');
|
|
const { viewTypes } = require('../challenge-types');
|
|
|
|
const backend = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Challenges/projects/backend/Show.tsx'
|
|
);
|
|
const classic = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Challenges/classic/show.tsx'
|
|
);
|
|
const frontend = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Challenges/projects/frontend/Show.tsx'
|
|
);
|
|
const codeally = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Challenges/codeally/show.tsx'
|
|
);
|
|
const intro = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Introduction/intro.tsx'
|
|
);
|
|
const superBlockIntro = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Introduction/super-block-intro.tsx'
|
|
);
|
|
const video = path.resolve(
|
|
__dirname,
|
|
'../../src/templates/Challenges/video/Show.tsx'
|
|
);
|
|
|
|
const views = {
|
|
backend,
|
|
classic,
|
|
modern: classic,
|
|
frontend,
|
|
video,
|
|
codeally
|
|
// quiz: Quiz
|
|
};
|
|
|
|
function getNextChallengePath(_node, index, nodeArray) {
|
|
const next = nodeArray[index + 1];
|
|
return next ? next.node.challenge.fields.slug : '/learn';
|
|
}
|
|
|
|
function getPrevChallengePath(_node, index, nodeArray) {
|
|
const prev = nodeArray[index - 1];
|
|
return prev ? prev.node.challenge.fields.slug : '/learn';
|
|
}
|
|
|
|
function getTemplateComponent(challengeType) {
|
|
return views[viewTypes[challengeType]];
|
|
}
|
|
|
|
exports.createChallengePages = function (createPage) {
|
|
return function ({ node: { challenge } }, index, allChallengeEdges) {
|
|
const {
|
|
certification,
|
|
superBlock,
|
|
block,
|
|
fields: { slug },
|
|
required = [],
|
|
template,
|
|
challengeType,
|
|
id
|
|
} = challenge;
|
|
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
|
// should remove one of them.
|
|
|
|
createPage({
|
|
path: slug,
|
|
component: getTemplateComponent(challengeType),
|
|
context: {
|
|
challengeMeta: {
|
|
certification,
|
|
superBlock,
|
|
block,
|
|
template,
|
|
required,
|
|
nextChallengePath: getNextChallengePath(
|
|
challenge,
|
|
index,
|
|
allChallengeEdges
|
|
),
|
|
prevChallengePath: getPrevChallengePath(
|
|
challenge,
|
|
index,
|
|
allChallengeEdges
|
|
),
|
|
id
|
|
},
|
|
projectPreview: getProjectPreviewConfig(challenge, allChallengeEdges),
|
|
slug
|
|
}
|
|
});
|
|
};
|
|
};
|
|
|
|
function getProjectPreviewConfig(challenge, allChallengeEdges) {
|
|
const { block, challengeOrder, usesMultifileEditor } = challenge;
|
|
|
|
const challengesInBlock = allChallengeEdges
|
|
.filter(({ node: { challenge } }) => challenge.block === block)
|
|
.map(({ node: { challenge } }) => challenge);
|
|
const lastChallenge = challengesInBlock[challengesInBlock.length - 1];
|
|
const solutionToLastChallenge = sortChallengeFiles(
|
|
lastChallenge.solutions[0] ?? []
|
|
);
|
|
const lastChallengeFiles = sortChallengeFiles(
|
|
lastChallenge.challengeFiles ?? []
|
|
);
|
|
const projectPreviewChallengeFiles = lastChallengeFiles.map((file, id) =>
|
|
createPoly({
|
|
...file,
|
|
contents: solutionToLastChallenge[id]?.contents ?? file.contents
|
|
})
|
|
);
|
|
|
|
return {
|
|
showProjectPreview: challengeOrder === 0 && usesMultifileEditor,
|
|
challengeData: {
|
|
challengeType: lastChallenge.challengeType,
|
|
challengeFiles: projectPreviewChallengeFiles,
|
|
required: lastChallenge.required,
|
|
template: lastChallenge.template
|
|
}
|
|
};
|
|
}
|
|
|
|
exports.createBlockIntroPages = function (createPage) {
|
|
return function (edge) {
|
|
const {
|
|
fields: { slug },
|
|
frontmatter: { block }
|
|
} = edge.node;
|
|
|
|
createPage({
|
|
path: slug,
|
|
component: intro,
|
|
context: {
|
|
block: dasherize(block),
|
|
slug
|
|
}
|
|
});
|
|
};
|
|
};
|
|
|
|
exports.createSuperBlockIntroPages = function (createPage) {
|
|
return function (edge) {
|
|
const {
|
|
fields: { slug },
|
|
frontmatter: { superBlock, certification }
|
|
} = edge.node;
|
|
|
|
if (!certification) {
|
|
throw Error(
|
|
`superBlockIntro page, '${superBlock}' must have certification in frontmatter`
|
|
);
|
|
}
|
|
|
|
// TODO: throw if it encounters an unknown certification. Also, handle
|
|
// coding-interview-prep. it's not a certification, but it is a superBlock.
|
|
|
|
createPage({
|
|
path: slug,
|
|
component: superBlockIntro,
|
|
context: {
|
|
certification,
|
|
superBlock,
|
|
slug
|
|
}
|
|
});
|
|
};
|
|
};
|