mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore: remove unused intro code (#65855)
This commit is contained in:
committed by
GitHub
parent
3a3b5e9395
commit
52e9bd83db
@@ -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',
|
||||
|
||||
+9
-44
@@ -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);
|
||||
const pageBuilder = createSuperBlockIntroPages(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'}
|
||||
|
||||
|
||||
`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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<typeof LearnLayout> {
|
||||
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 (
|
||||
<LearnLayout>
|
||||
<Helmet>
|
||||
<title>{blockTitle}</title>
|
||||
</Helmet>
|
||||
<Container className='intro-layout-container'>
|
||||
<FullWidthRow>
|
||||
<div
|
||||
className='intro-layout'
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
</FullWidthRow>
|
||||
<FullWidthRow>
|
||||
<ButtonLink block size='large' href={firstLessonPath || '/learn'}>
|
||||
{t('buttons.first-lesson')}
|
||||
</ButtonLink>
|
||||
<Spacer size='xs' />
|
||||
<ButtonLink block size='large' href='/learn'>
|
||||
{t('buttons.view-curriculum')}
|
||||
</ButtonLink>
|
||||
<Spacer size='xs' />
|
||||
<hr />
|
||||
</FullWidthRow>
|
||||
</Container>
|
||||
</LearnLayout>
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
/* eslint-disable filenames-simple/naming-convention */
|
||||
import { createLintStagedConfig } from '@freecodecamp/eslint-config/lintstaged';
|
||||
|
||||
export default createLintStagedConfig(import.meta.dirname);
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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 <team@freecodecamp.org>",
|
||||
"main": "gatsby-node.js",
|
||||
"peerDependencies": {
|
||||
"gatsby": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@freecodecamp/eslint-config": "workspace:*",
|
||||
"eslint": "^9.39.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user