From 52e9bd83db3076c20e8adb33e5b88a99152eae23 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Tue, 17 Feb 2026 18:22:22 +0100 Subject: [PATCH] chore: remove unused intro code (#65855) --- client/gatsby-config.js | 30 ------ client/gatsby-node.js | 55 ++--------- client/src/templates/Introduction/intro.tsx | 91 ------------------- client/utils/gatsby/challenge-page-creator.js | 23 ----- .../.lintstagedrc.mjs | 4 - .../eslint.config.mjs | 13 --- .../gatsby-node.js | 21 ----- .../gatsby-remark-node-identity/package.json | 31 ------- 8 files changed, 10 insertions(+), 258 deletions(-) delete mode 100644 client/src/templates/Introduction/intro.tsx delete mode 100644 tools/client-plugins/gatsby-remark-node-identity/.lintstagedrc.mjs delete mode 100644 tools/client-plugins/gatsby-remark-node-identity/eslint.config.mjs delete mode 100644 tools/client-plugins/gatsby-remark-node-identity/gatsby-node.js delete mode 100644 tools/client-plugins/gatsby-remark-node-identity/package.json diff --git a/client/gatsby-config.js b/client/gatsby-config.js index 7f434828997..fa47aedc8ac 100644 --- a/client/gatsby-config.js +++ b/client/gatsby-config.js @@ -65,36 +65,6 @@ module.exports = { { resolve: 'gatsby-transformer-remark' }, - { - resolve: require.resolve( - '../tools/client-plugins/gatsby-remark-node-identity' - ), - options: { - identity: 'blockIntroMarkdown', - predicate: ({ frontmatter }) => { - if (!frontmatter) { - return false; - } - const { title, block, superBlock } = frontmatter; - return title && block && superBlock; - } - } - }, - { - resolve: require.resolve( - '../tools/client-plugins/gatsby-remark-node-identity' - ), - options: { - identity: 'superBlockIntroMarkdown', - predicate: ({ frontmatter }) => { - if (!frontmatter) { - return false; - } - const { title, block, superBlock } = frontmatter; - return title && !block && superBlock; - } - } - }, 'gatsby-plugin-remove-serviceworker', { resolve: 'gatsby-plugin-schema-snapshot', diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 576d42dc6f8..f139d2a827b 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -1,21 +1,10 @@ const { createFilePath } = require('gatsby-source-filesystem'); -// TODO: ideally we'd remove lodash and just use lodash-es, but we can't require -// es modules here. -const uniq = require('lodash/uniq'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); const webpack = require('webpack'); const { SuperBlocks } = require('@freecodecamp/shared/config/curriculum'); const env = require('./config/env.json'); -const { - createBlockIntroPages, - createSuperBlockIntroPages -} = require('./utils/gatsby'); - -const createByIdentityMap = { - blockIntroMarkdown: createBlockIntroPages, - superBlockIntroMarkdown: createSuperBlockIntroPages -}; +const { createSuperBlockIntroPages } = require('./utils/gatsby'); exports.onCreateNode = function onCreateNode({ node, actions, getNode }) { const { createNodeField } = actions; @@ -79,11 +68,9 @@ exports.createPages = async function createPages({ node { fields { slug - nodeIdentity } frontmatter { certification - block superBlock title } @@ -94,16 +81,6 @@ exports.createPages = async function createPages({ } `); - const blocks = uniq( - result.data.allChallengeNode.edges.map( - ({ - node: { - challenge: { block } - } - }) => block - ) - ); - // Includes upcoming superBlocks const allSuperBlocks = Object.values(SuperBlocks); @@ -115,33 +92,21 @@ exports.createPages = async function createPages({ } = edge; if (!fields) { - return; + throw Error( + "'fields' property missing (this should be added in onCreateNode)" + ); } - const { slug, nodeIdentity } = fields; + const { slug } = fields; if (slug.includes('LICENCE')) { return; } - if (nodeIdentity === 'blockIntroMarkdown') { - if (!blocks.includes(frontmatter.block)) { - return; - } - } else if (!allSuperBlocks.includes(frontmatter.superBlock)) { - return; + + if (!allSuperBlocks.includes(frontmatter.superBlock)) { + throw Error(`Unknown superblock ${frontmatter.superBlock}`); } - try { - const pageBuilder = createByIdentityMap[nodeIdentity](createPage); - pageBuilder(edge); - } catch (e) { - console.log(e); - console.log(` - ident: ${nodeIdentity} does not belong to a function - - ${frontmatter ? JSON.stringify(edge.node) : 'no frontmatter'} - - - `); - } + const pageBuilder = createSuperBlockIntroPages(createPage); + pageBuilder(edge); }); }; diff --git a/client/src/templates/Introduction/intro.tsx b/client/src/templates/Introduction/intro.tsx deleted file mode 100644 index 96196f546c2..00000000000 --- a/client/src/templates/Introduction/intro.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { graphql } from 'gatsby'; -import React from 'react'; -import Helmet from 'react-helmet'; -import { useTranslation } from 'react-i18next'; - -import { Container, Spacer } from '@freecodecamp/ui'; -import { ButtonLink } from '../../components/helpers'; -import FullWidthRow from '../../components/helpers/full-width-row'; -import LearnLayout from '../../components/layouts/learn'; -import type { MarkdownRemark, AllChallengeNode } from '../../redux/prop-types'; - -import './intro.css'; - -function IntroductionPage({ - data: { markdownRemark, allChallengeNode } -}: { - data: { - markdownRemark: MarkdownRemark; - allChallengeNode: AllChallengeNode; - }; -}): React.FunctionComponentElement { - const { t } = useTranslation(); - const { - html, - frontmatter: { block, superBlock } - } = markdownRemark; - const firstLesson = - allChallengeNode && allChallengeNode.edges[0].node.challenge; - const firstLessonPath = firstLesson - ? firstLesson.fields.slug - : '/strange-place'; - const blockTitle = - t(`intro:${superBlock}.blocks.${block}.title`) + ' | freeCodeCamp.org'; - return ( - - - {blockTitle} - - - -
- - - - {t('buttons.first-lesson')} - - - - {t('buttons.view-curriculum')} - - -
-
- - - ); -} - -IntroductionPage.displayName = 'IntroductionPage'; - -export default IntroductionPage; - -export const query = graphql` - query IntroPageBySlug($id: String!, $block: String!) { - markdownRemark(id: { eq: $id }) { - frontmatter { - block - superBlock - } - html - } - allChallengeNode( - sort: { challenge: { challengeOrder: ASC } } - filter: { challenge: { block: { eq: $block } } } - limit: 1 - ) { - edges { - node { - challenge { - fields { - slug - } - } - } - } - } - } -`; diff --git a/client/utils/gatsby/challenge-page-creator.js b/client/utils/gatsby/challenge-page-creator.js index 62805d5dcc6..ba2a89ef3eb 100644 --- a/client/utils/gatsby/challenge-page-creator.js +++ b/client/utils/gatsby/challenge-page-creator.js @@ -17,10 +17,6 @@ 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' @@ -169,25 +165,6 @@ function getProjectPreviewConfig(challenge, allChallengeNodes) { }; } -exports.createBlockIntroPages = function (createPage) { - return function (edge) { - const { - fields: { slug }, - frontmatter: { block }, - id - } = edge.node; - - createPage({ - path: slug, - component: intro, - context: { - block, - id - } - }); - }; -}; - exports.createSuperBlockIntroPages = function (createPage) { return function (edge) { const { diff --git a/tools/client-plugins/gatsby-remark-node-identity/.lintstagedrc.mjs b/tools/client-plugins/gatsby-remark-node-identity/.lintstagedrc.mjs deleted file mode 100644 index 2cb8879f45f..00000000000 --- a/tools/client-plugins/gatsby-remark-node-identity/.lintstagedrc.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/* eslint-disable filenames-simple/naming-convention */ -import { createLintStagedConfig } from '@freecodecamp/eslint-config/lintstaged'; - -export default createLintStagedConfig(import.meta.dirname); diff --git a/tools/client-plugins/gatsby-remark-node-identity/eslint.config.mjs b/tools/client-plugins/gatsby-remark-node-identity/eslint.config.mjs deleted file mode 100644 index dad09ad83c2..00000000000 --- a/tools/client-plugins/gatsby-remark-node-identity/eslint.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import { configTypeChecked } from '@freecodecamp/eslint-config/base'; -import globals from 'globals'; - -export default [ - ...configTypeChecked, - { - languageOptions: { - globals: { - ...globals.node // TODO: migrate to ESM and remove globals - } - } - } -]; diff --git a/tools/client-plugins/gatsby-remark-node-identity/gatsby-node.js b/tools/client-plugins/gatsby-remark-node-identity/gatsby-node.js deleted file mode 100644 index 9afb0523c5b..00000000000 --- a/tools/client-plugins/gatsby-remark-node-identity/gatsby-node.js +++ /dev/null @@ -1,21 +0,0 @@ -exports.onCreateNode = function remarkNodeIdentityOnCreateNode( - { node, reporter, actions }, - { predicate, identity } -) { - if (typeof predicate !== 'function') { - reporter.panic( - 'Please supply a predicate function to `gatsby-remark-node-identity`' - ); - } - if (typeof identity !== 'string' || identity.length === 0) { - reporter.panic( - '`gatsby-remark-node-identity` requires an identify string to add to nodes ' + - 'that match the predicate' - ); - } - const { createNodeField } = actions; - if (predicate(node)) { - createNodeField({ node, name: 'nodeIdentity', value: identity }); - } - return node; -}; diff --git a/tools/client-plugins/gatsby-remark-node-identity/package.json b/tools/client-plugins/gatsby-remark-node-identity/package.json deleted file mode 100644 index c46feecbc10..00000000000 --- a/tools/client-plugins/gatsby-remark-node-identity/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@freecodecamp/gatsby-remark-node-identity", - "version": "0.0.1", - "description": "The freeCodeCamp.org open-source codebase and curriculum", - "license": "BSD-3-Clause", - "private": true, - "engines": { - "node": ">=24", - "pnpm": ">=10" - }, - "scripts": { - "lint": "eslint --max-warnings 0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/freeCodeCamp/freeCodeCamp.git" - }, - "bugs": { - "url": "https://github.com/freeCodeCamp/freeCodeCamp/issues" - }, - "homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme", - "author": "freeCodeCamp ", - "main": "gatsby-node.js", - "peerDependencies": { - "gatsby": "^5.0.0" - }, - "devDependencies": { - "@freecodecamp/eslint-config": "workspace:*", - "eslint": "^9.39.1" - } -}