diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 55d2ce5c86b5cb..5431c009b2105b 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -23,11 +23,7 @@ exports.onCreateNode = function onCreateNode({ node, actions, getNode }) { if (node.internal.type === 'MarkdownRemark') { const slug = createFilePath({ node, getNode }); if (!slug.includes('LICENSE')) { - const { - frontmatter: { component = '' } - } = node; createNodeField({ node, name: 'slug', value: slug }); - createNodeField({ node, name: 'component', value: component }); } } }; @@ -74,6 +70,7 @@ exports.createPages = async function createPages({ ) { edges { node { + id challenge { block blockType @@ -122,7 +119,6 @@ exports.createPages = async function createPages({ fields { slug nodeIdentity - component } frontmatter { certification @@ -130,9 +126,7 @@ exports.createPages = async function createPages({ superBlock title } - htmlAst id - excerpt } } } diff --git a/client/src/redux/prop-types.ts b/client/src/redux/prop-types.ts index 56e3d038c07d74..349a175a9132ff 100644 --- a/client/src/redux/prop-types.ts +++ b/client/src/redux/prop-types.ts @@ -19,8 +19,6 @@ export type CurrentCert = { }; export type MarkdownRemark = { - fields: [{ component: string; nodeIdentity: string; slug: string }]; - fileAbsolutePath: string; frontmatter: { block: string; superBlock: SuperBlocks; @@ -28,23 +26,8 @@ export type MarkdownRemark = { certification: string; title: CertTitle; }; - headings: [ - { - depth: number; - value: string; - id: string; - } - ]; html: string; - htmlAst: Record; id: string; - rawMarkdownBody: string; - timeToRead: number; - wordCount: { - paragraphs: number; - sentences: number; - words: number; - }; }; export type MultipleChoiceAnswer = { diff --git a/client/src/templates/Challenges/classic/show.tsx b/client/src/templates/Challenges/classic/show.tsx index c3aa0ffd859e86..440387aa894b7f 100644 --- a/client/src/templates/Challenges/classic/show.tsx +++ b/client/src/templates/Challenges/classic/show.tsx @@ -532,8 +532,8 @@ ShowClassic.displayName = 'ShowClassic'; export default connect(mapStateToProps, mapDispatchToProps)(ShowClassic); export const query = graphql` - query ClassicChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query ClassicChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { block demoType diff --git a/client/src/templates/Challenges/codeally/show.tsx b/client/src/templates/Challenges/codeally/show.tsx index 3845a207ad4623..0214d231c9b814 100644 --- a/client/src/templates/Challenges/codeally/show.tsx +++ b/client/src/templates/Challenges/codeally/show.tsx @@ -426,8 +426,8 @@ export default connect( // GraphQL export const query = graphql` - query CodeAllyChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query CodeAllyChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { block fields { diff --git a/client/src/templates/Challenges/dialogue/show.tsx b/client/src/templates/Challenges/dialogue/show.tsx index c8b33a37abe028..d9139420f01deb 100644 --- a/client/src/templates/Challenges/dialogue/show.tsx +++ b/client/src/templates/Challenges/dialogue/show.tsx @@ -329,8 +329,8 @@ export default connect( )(withTranslation()(ShowDialogue)); export const query = graphql` - query Dialogue($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query Dialogue($id: String!) { + challengeNode(id: { eq: $id }) { challenge { videoId title diff --git a/client/src/templates/Challenges/exam/show.tsx b/client/src/templates/Challenges/exam/show.tsx index ea00cb4868c5b7..2ebbe3c7566116 100644 --- a/client/src/templates/Challenges/exam/show.tsx +++ b/client/src/templates/Challenges/exam/show.tsx @@ -596,8 +596,8 @@ export default connect( // GraphQL export const query = graphql` - query ExamChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query ExamChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { block challengeType diff --git a/client/src/templates/Challenges/fill-in-the-blank/show.tsx b/client/src/templates/Challenges/fill-in-the-blank/show.tsx index 5b625f6fb2f94f..3eb056f17e674f 100644 --- a/client/src/templates/Challenges/fill-in-the-blank/show.tsx +++ b/client/src/templates/Challenges/fill-in-the-blank/show.tsx @@ -429,8 +429,8 @@ export default connect( )(withTranslation()(ShowFillInTheBlank)); export const query = graphql` - query FillInTheBlankChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query FillInTheBlankChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { title description diff --git a/client/src/templates/Challenges/ms-trophy/show.tsx b/client/src/templates/Challenges/ms-trophy/show.tsx index 7ace165b6afeae..b1d91303b45b39 100644 --- a/client/src/templates/Challenges/ms-trophy/show.tsx +++ b/client/src/templates/Challenges/ms-trophy/show.tsx @@ -250,8 +250,8 @@ export default connect( )(withTranslation()(MsTrophy)); export const query = graphql` - query MsTrophyChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query MsTrophyChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { title description diff --git a/client/src/templates/Challenges/odin/show.tsx b/client/src/templates/Challenges/odin/show.tsx index 04b2a1898dc407..8ce538733481ba 100644 --- a/client/src/templates/Challenges/odin/show.tsx +++ b/client/src/templates/Challenges/odin/show.tsx @@ -452,8 +452,8 @@ export default connect( )(withTranslation()(ShowOdin)); export const query = graphql` - query TheOdinProject($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query TheOdinProject($id: String!) { + challengeNode(id: { eq: $id }) { challenge { videoId videoLocaleIds { diff --git a/client/src/templates/Challenges/projects/backend/show.tsx b/client/src/templates/Challenges/projects/backend/show.tsx index bc6365a64a9d01..32db2649103eaa 100644 --- a/client/src/templates/Challenges/projects/backend/show.tsx +++ b/client/src/templates/Challenges/projects/backend/show.tsx @@ -282,8 +282,8 @@ export default connect( )(withTranslation()(BackEnd)); export const query = graphql` - query BackendChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query BackendChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { forumTopicId title diff --git a/client/src/templates/Challenges/projects/frontend/show.tsx b/client/src/templates/Challenges/projects/frontend/show.tsx index f241bb72cae698..03a61f7fa1d6eb 100644 --- a/client/src/templates/Challenges/projects/frontend/show.tsx +++ b/client/src/templates/Challenges/projects/frontend/show.tsx @@ -228,8 +228,8 @@ export default connect( )(withTranslation()(Project)); export const query = graphql` - query ProjectChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query ProjectChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { forumTopicId title diff --git a/client/src/templates/Challenges/video/show.tsx b/client/src/templates/Challenges/video/show.tsx index a54b246c76b876..faa2180fa785af 100644 --- a/client/src/templates/Challenges/video/show.tsx +++ b/client/src/templates/Challenges/video/show.tsx @@ -359,8 +359,8 @@ export default connect( )(withTranslation()(ShowVideo)); export const query = graphql` - query VideoChallenge($slug: String!) { - challengeNode(challenge: { fields: { slug: { eq: $slug } } }) { + query VideoChallenge($id: String!) { + challengeNode(id: { eq: $id }) { challenge { videoId videoLocaleIds { diff --git a/client/src/templates/Introduction/intro.tsx b/client/src/templates/Introduction/intro.tsx index 97e9dbf27dbdb4..bf707204bca2e7 100644 --- a/client/src/templates/Introduction/intro.tsx +++ b/client/src/templates/Introduction/intro.tsx @@ -64,8 +64,8 @@ IntroductionPage.displayName = 'IntroductionPage'; export default IntroductionPage; export const query = graphql` - query IntroPageBySlug($slug: String!, $block: String!) { - markdownRemark(fields: { slug: { eq: $slug } }) { + query IntroPageBySlug($id: String!, $block: String!) { + markdownRemark(id: { eq: $id }) { frontmatter { block superBlock diff --git a/client/src/templates/Introduction/super-block-intro.tsx b/client/src/templates/Introduction/super-block-intro.tsx index 97c7ade85c90c9..83682ededea799 100644 --- a/client/src/templates/Introduction/super-block-intro.tsx +++ b/client/src/templates/Introduction/super-block-intro.tsx @@ -276,8 +276,8 @@ export default connect( )(withTranslation()(memo(SuperBlockIntroductionPage))); export const query = graphql` - query SuperBlockIntroPageBySlug($slug: String!, $superBlock: String!) { - markdownRemark(fields: { slug: { eq: $slug } }) { + query SuperBlockIntroPageBySlug($id: String!, $superBlock: String!) { + markdownRemark(id: { eq: $id }) { frontmatter { certification superBlock diff --git a/client/utils/gatsby/challenge-page-creator.js b/client/utils/gatsby/challenge-page-creator.js index 105bbf2b7d3868..e05746df383bac 100644 --- a/client/utils/gatsby/challenge-page-creator.js +++ b/client/utils/gatsby/challenge-page-creator.js @@ -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 } }); };