mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
refactor: remove dasherize (#50620)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -170,10 +170,6 @@ config/superblocks.js
|
||||
config/superblocks.test.js
|
||||
|
||||
### Generated utils files ###
|
||||
utils/block-nameify.js
|
||||
utils/block-nameify.test.js
|
||||
utils/slugs.js
|
||||
utils/slugs.test.js
|
||||
utils/index.js
|
||||
utils/get-lines.js
|
||||
utils/get-lines.test.js
|
||||
|
||||
@@ -12,10 +12,6 @@ config/certification-settings.js
|
||||
config/donation-settings.js
|
||||
config/superblocks.js
|
||||
config/superblocks.test.js
|
||||
utils/block-nameify.js
|
||||
utils/block-nameify.test.js
|
||||
utils/slugs.js
|
||||
utils/slugs.test.js
|
||||
utils/index.js
|
||||
utils/get-lines.js
|
||||
utils/get-lines.test.js
|
||||
|
||||
@@ -77,6 +77,7 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
||||
block
|
||||
certification
|
||||
challengeType
|
||||
dashedName
|
||||
fields {
|
||||
slug
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { withTranslation } from 'react-i18next';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import { dasherize } from '../../../../../utils/slugs';
|
||||
import Login from '../../../components/Header/components/login';
|
||||
import { executeGA } from '../../../redux/actions';
|
||||
import {
|
||||
@@ -40,7 +39,7 @@ const mapStateToProps = createSelector(
|
||||
|
||||
(
|
||||
challengeFiles: ChallengeFiles,
|
||||
{ title }: { title: string; id: string },
|
||||
{ dashedName }: { dashedName: string },
|
||||
completedChallengesIds: string[],
|
||||
isOpen: boolean,
|
||||
isSignedIn: boolean,
|
||||
@@ -48,7 +47,7 @@ const mapStateToProps = createSelector(
|
||||
message: string
|
||||
) => ({
|
||||
challengeFiles,
|
||||
title,
|
||||
dashedName,
|
||||
completedChallengesIds,
|
||||
isOpen,
|
||||
isSignedIn,
|
||||
@@ -144,16 +143,20 @@ class CompletionModal extends Component<
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
const { close, isOpen, isSignedIn, message, t, title, submitChallenge } =
|
||||
this.props;
|
||||
const {
|
||||
close,
|
||||
isOpen,
|
||||
isSignedIn,
|
||||
message,
|
||||
t,
|
||||
dashedName,
|
||||
submitChallenge
|
||||
} = this.props;
|
||||
|
||||
if (isOpen) {
|
||||
executeGA({ event: 'pageview', pagePath: '/completion-modal' });
|
||||
}
|
||||
// normally dashedName should be graphQL queried and then passed around,
|
||||
// but it's only used to make a nice filename for downloading, so dasherize
|
||||
// is fine here.
|
||||
const dashedName = dasherize(title);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
animation={false}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { AllChallengesInfo } from '../redux/prop-types';
|
||||
import { dasherize } from '../../../utils/slugs';
|
||||
import { isFinalProject } from '../../utils/challenge-types';
|
||||
|
||||
export function getCompletedPercentage(
|
||||
@@ -43,9 +42,7 @@ export const getCurrentBlockIds = (
|
||||
const { challengeEdges, certificateNodes } = allChallengesInfo;
|
||||
const currentCertificateIds =
|
||||
certificateNodes
|
||||
.filter(
|
||||
node => dasherize(node.challenge.certification) === certification
|
||||
)[0]
|
||||
.filter(node => node.challenge.certification === certification)[0]
|
||||
?.challenge.tests.map(test => test.id) ?? [];
|
||||
const currentBlockIds = challengeEdges
|
||||
.filter(edge => edge.node.challenge.block === block)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const path = require('path');
|
||||
const { dasherize } = require('../../../utils/slugs');
|
||||
const { sortChallengeFiles } = require('../../../utils/sort-challengefiles');
|
||||
const { challengeTypes, viewTypes } = require('../challenge-types');
|
||||
|
||||
@@ -79,6 +78,7 @@ function getTemplateComponent(challengeType) {
|
||||
exports.createChallengePages = function (createPage) {
|
||||
return function ({ node: { challenge } }, index, allChallengeEdges) {
|
||||
const {
|
||||
dashedName,
|
||||
certification,
|
||||
superBlock,
|
||||
block,
|
||||
@@ -96,6 +96,7 @@ exports.createChallengePages = function (createPage) {
|
||||
component: getTemplateComponent(challengeType),
|
||||
context: {
|
||||
challengeMeta: {
|
||||
dashedName,
|
||||
certification,
|
||||
superBlock,
|
||||
block,
|
||||
@@ -163,7 +164,7 @@ exports.createBlockIntroPages = function (createPage) {
|
||||
path: slug,
|
||||
component: intro,
|
||||
context: {
|
||||
block: dasherize(block),
|
||||
block,
|
||||
slug
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Caesars Cipher Project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "build-a-caesars-cipher-project",
|
||||
"usesMultifileEditor": false,
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 17,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Caesars Cipher"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Cash Register Project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "build-a-cash-register-project",
|
||||
"usesMultifileEditor": false,
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 14,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Cash Register"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Celestial Bodies Database Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-celestial-bodies-database-project",
|
||||
"order": 2,
|
||||
"helpCategory": "Backend Development",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Celestial Bodies Database"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Data Graph Explorer Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-data-graph-explorer-project",
|
||||
"order": 19,
|
||||
"helpCategory": "Python",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Data Graph Explorer"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Financial Calculator Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-financial-calculator-project",
|
||||
"order": 17,
|
||||
"helpCategory": "Python",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Financial Calculator"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Graphing Calculator Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-graphing-calculator-project",
|
||||
"order": 11,
|
||||
"helpCategory": "Python",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Graphing Calculator"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Multi-Function Calculator Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-multi-function-calculator-project",
|
||||
"order": 6,
|
||||
"helpCategory": "Python",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Multi-Function Calculator"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Number Guessing Game Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-number-guessing-game-project",
|
||||
"order": 13,
|
||||
"helpCategory": "Backend Development",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Number Guessing Game"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Palindrome Checker Project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "build-a-palindrome-checker-project",
|
||||
"usesMultifileEditor": false,
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 3,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Palindrome Checker"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Periodic Table Database Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-periodic-table-database-project",
|
||||
"order": 12,
|
||||
"helpCategory": "Backend Development",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Periodic Table Database"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Personal Portfolio Webpage Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-personal-portfolio-webpage-project",
|
||||
"usesMultifileEditor": true,
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 19,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Personal Portfolio Webpage"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Product Landing Page Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-product-landing-page-project",
|
||||
"usesMultifileEditor": true,
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 16,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Product Landing Page"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Roman Numeral Converter Project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "build-a-roman-numeral-converter-project",
|
||||
"usesMultifileEditor": false,
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 6,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Roman Numeral Converter"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Salon Appointment Scheduler Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-salon-appointment-scheduler-project",
|
||||
"order": 9,
|
||||
"helpCategory": "Backend Development",
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Salon Appointment Scheduler"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Survey Form Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-survey-form-project",
|
||||
"usesMultifileEditor": true,
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 4,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Survey Form"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Technical Documentation Page Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-technical-documentation-page-project",
|
||||
"usesMultifileEditor": true,
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 13,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Technical Documentation Page"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Telephone Number Validator Project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "build-a-telephone-number-validator-project",
|
||||
"usesMultifileEditor": false,
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 10,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Telephone Number Validator"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a Tribute Page Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-tribute-page-project",
|
||||
"usesMultifileEditor": true,
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 9,
|
||||
@@ -14,4 +15,4 @@
|
||||
"Build a Tribute Page"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build a World Cup Database Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-a-world-cup-database-project",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 6,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a World Cup Database"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Build Three Math Games Project",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "build-three-math-games-project",
|
||||
"helpCategory": "Python",
|
||||
"order": 13,
|
||||
"time": "30 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build Three Math Games"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Advanced Bash by Building a Kitty Ipsum Translator",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-advanced-bash-by-building-a-kitty-ipsum-translator",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 7,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Kitty Ipsum Translator"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Bash and SQL by Building a Bike Rental Shop",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-bash-and-sql-by-building-a-bike-rental-shop",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 8,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Bike Rental Shop"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Bash by Building a Boilerplate",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-bash-by-building-a-boilerplate",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 0,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Boilerplate"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Bash Scripting by Building Five Programs",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-bash-scripting-by-building-five-programs",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 3,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build Five Programs"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Git by Building an SQL Reference Object",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-git-by-building-an-sql-reference-object",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 11,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build an SQL Reference Object"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Nano by Building a Castle",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-nano-by-building-a-castle",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 10,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Castle"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn Relational Databases by Building a Mario Database",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-relational-databases-by-building-a-mario-database",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 1,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Mario Database"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn SQL by Building a Student Database: Part 1",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-sql-by-building-a-student-database-part-1",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 4,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Student Database: Part 1"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "Learn SQL by Building a Student Database: Part 2",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "learn-sql-by-building-a-student-database-part-2",
|
||||
"helpCategory": "Backend Development",
|
||||
"order": 5,
|
||||
"time": "5 hours",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Student Database: Part 2"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "project euler problems 1 to 100",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "project-euler-problems-1-to-100",
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 0,
|
||||
"time": "",
|
||||
@@ -409,4 +410,4 @@
|
||||
"Problem 100: Arranged probability"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "project euler problems 101 to 200",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "project-euler-problems-101-to-200",
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 1,
|
||||
"time": "",
|
||||
@@ -409,4 +410,4 @@
|
||||
"Problem 200: Find the 200th prime-proof sqube containing the contiguous sub-string \"200\""
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "project euler problems 201 to 300",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "project-euler-problems-201-to-300",
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 2,
|
||||
"time": "",
|
||||
@@ -409,4 +410,4 @@
|
||||
"Problem 300: Protein folding"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "project euler problems 301 to 400",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "project-euler-problems-301-to-400",
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 3,
|
||||
"time": "",
|
||||
@@ -409,4 +410,4 @@
|
||||
"Problem 400: Fibonacci tree game"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "project euler problems 401 to 480",
|
||||
"isUpcomingChange": false,
|
||||
"dashedName": "project-euler-problems-401-to-480",
|
||||
"helpCategory": "JavaScript",
|
||||
"order": 4,
|
||||
"time": "",
|
||||
@@ -329,4 +330,4 @@
|
||||
"Problem 480: The Last Question"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "TOP build a recipe project",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "top-build-a-recipe-project",
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 1,
|
||||
"time": "",
|
||||
@@ -13,4 +14,4 @@
|
||||
"Build a Recipe Page Project"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "TOP Learn CSS Foundations Projects",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "top-learn-css-foundations-projects",
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 3,
|
||||
"time": "",
|
||||
@@ -29,4 +30,4 @@
|
||||
"CSS Foundations Exercise E"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "TOP Learn CSS Foundations",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "top-learn-css-foundations",
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 2,
|
||||
"time": "",
|
||||
@@ -41,4 +42,4 @@
|
||||
"CSS Foundations Question H"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "TOP Learn HTML Foundations",
|
||||
"isUpcomingChange": true,
|
||||
"dashedName": "top-learn-html-foundations",
|
||||
"helpCategory": "HTML-CSS",
|
||||
"order": 0,
|
||||
"time": "",
|
||||
@@ -121,4 +122,4 @@
|
||||
"Links and Images Question D"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ const {
|
||||
|
||||
const { isAuditedCert } = require('../utils/is-audited');
|
||||
const { createPoly } = require('../utils/polyvinyl');
|
||||
const { dasherize } = require('../utils/slugs');
|
||||
const { getSuperOrder, getSuperBlockFromDir } = require('./utils');
|
||||
|
||||
const access = util.promisify(fs.access);
|
||||
@@ -293,7 +292,12 @@ Challenges that have been already audited cannot fall back to their English vers
|
||||
([id]) => id === challenge.id
|
||||
);
|
||||
|
||||
challenge.block = meta.name ? dasherize(meta.name) : null;
|
||||
if (!meta.dashedName)
|
||||
throw Error(
|
||||
`The 'meta.json' file for the block with challenge '${challenge.title}' has no 'dashedName' property`
|
||||
);
|
||||
|
||||
challenge.block = meta.dashedName;
|
||||
challenge.hasEditableBoundaries = !!meta.hasEditableBoundaries;
|
||||
challenge.order = meta.order;
|
||||
// const superOrder = getSuperOrder(meta.superBlock);
|
||||
|
||||
@@ -1,51 +1,23 @@
|
||||
import { dasherize } from './slugs';
|
||||
|
||||
const idToTitle = new Map(
|
||||
const idToPath = new Map(
|
||||
Object.entries({
|
||||
'561add10cb82ac38a17523bc': 'Back End Development and APIs',
|
||||
'5a553ca864b52e1d8bceea14': 'Data Visualization',
|
||||
'561acd10cb82ac38a17513bc': 'Front End Development Libraries',
|
||||
'5e611829481575a52dc59c0e': 'Quality Assurance',
|
||||
'5e6021435ac9d0ecd8b94b00': 'Information Security',
|
||||
'561abd10cb81ac38a17513bc': 'JavaScript Algorithms and Data Structures',
|
||||
'561add10cb82ac38a17513bc': 'Responsive Web Design',
|
||||
'660add10cb82ac38a17513be': 'Legacy Back End',
|
||||
'561add10cb82ac39a17513bc': 'Legacy Data Visualization',
|
||||
'561add10cb82ac38a17513be': 'Legacy Front End',
|
||||
'561add10cb82ac38a17213bc':
|
||||
'Legacy Information Security and Quality Assurance',
|
||||
'561add10cb82ac38a17213bd': 'Legacy Full Stack',
|
||||
'5e44431b903586ffb414c951': 'Scientific Computing with Python',
|
||||
'5e46fc95ac417301a38fb934': 'Data Analysis with Python',
|
||||
'5e46fc95ac417301a38fb935': 'Machine Learning with Python'
|
||||
'561add10cb82ac38a17523bc': 'back-end-development-and-apis',
|
||||
'5a553ca864b52e1d8bceea14': 'data-visualization',
|
||||
'561acd10cb82ac38a17513bc': 'front-end-development-libraries',
|
||||
'5e611829481575a52dc59c0e': 'quality-assurance-v7',
|
||||
'5e6021435ac9d0ecd8b94b00': 'information-security-v7',
|
||||
'561abd10cb81ac38a17513bc': 'javascript-algorithms-and-data-structures',
|
||||
'561add10cb82ac38a17513bc': 'responsive-web-design',
|
||||
'660add10cb82ac38a17513be': 'legacy-back-end',
|
||||
'561add10cb82ac39a17513bc': 'legacy-data-visualization',
|
||||
'561add10cb82ac38a17513be': 'legacy-front-end',
|
||||
'561add10cb82ac38a17213bc': 'information-security-and-quality-assurance',
|
||||
'561add10cb82ac38a17213bd': 'full-stack',
|
||||
'5e44431b903586ffb414c951': 'scientific-computing-with-python-v7',
|
||||
'5e46fc95ac417301a38fb934': 'data-analysis-with-python-v7',
|
||||
'5e46fc95ac417301a38fb935': 'machine-learning-with-python-v7'
|
||||
})
|
||||
);
|
||||
|
||||
const idToPath = new Map<string, string>();
|
||||
|
||||
// Keep the timeline slugs the same so
|
||||
// we don't break existing links
|
||||
const specialPaths: Record<string, string> = {
|
||||
'Legacy Full Stack': 'Full Stack',
|
||||
'Legacy Information Security and Quality Assurance':
|
||||
'Information Security and Quality Assurance',
|
||||
'Scientific Computing with Python': 'Scientific Computing with Python V7',
|
||||
'Data Analysis with Python': 'Data Analysis with Python V7',
|
||||
'Machine Learning with Python': 'Machine Learning with Python V7',
|
||||
'Quality Assurance': 'Quality Assurance V7',
|
||||
'Information Security': 'Information Security V7'
|
||||
};
|
||||
|
||||
for (const [id, title] of idToTitle) {
|
||||
if (specialPaths[title]) {
|
||||
idToPath.set(id, dasherize(specialPaths[title]));
|
||||
} else {
|
||||
idToPath.set(id, dasherize(title));
|
||||
}
|
||||
}
|
||||
|
||||
export const getCertIds = (): IterableIterator<string> => idToPath.keys();
|
||||
export const getPathFromID = (id: string): string | undefined =>
|
||||
idToPath.get(id);
|
||||
export const getTitleFromId = (id: string): string | undefined =>
|
||||
idToTitle.get(id);
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { dasherize, nameify, unDasherize } from './slugs';
|
||||
|
||||
describe('dasherize', () => {
|
||||
it('returns a string', () => {
|
||||
expect(dasherize('')).toBe('');
|
||||
});
|
||||
it('converts characters to lower case', () => {
|
||||
expect(dasherize('UPPERCASE')).toBe('uppercase');
|
||||
});
|
||||
it('converts spaces to dashes', () => {
|
||||
expect(dasherize('the space between')).toBe('the-space--between');
|
||||
});
|
||||
|
||||
it('converts dots to dashes', () => {
|
||||
expect(dasherize('the..dots.. between')).toBe('the--dots---between');
|
||||
});
|
||||
|
||||
it('trims off surrounding whitespace', () => {
|
||||
expect(dasherize(' the space between ')).toBe('the-space--between');
|
||||
});
|
||||
|
||||
it('removes everything except letters, numbers and -', () => {
|
||||
expect(dasherize('1a!"£$%^*()_+=-.b2')).toBe('1a--b2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('nameify', () => {
|
||||
it('returns a string', () => {
|
||||
expect(nameify('')).toBe('');
|
||||
});
|
||||
it('removes everything except letters, numbers and spaces', () => {
|
||||
expect(nameify('1A !"£$%^*()_+=-.b 2')).toBe('1A b 2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('unDasherize', () => {
|
||||
it('returns a string', () => {
|
||||
expect(unDasherize('')).toBe('');
|
||||
});
|
||||
it('converts dashes to spaces', () => {
|
||||
expect(unDasherize('the-space--between')).toBe('the space between');
|
||||
});
|
||||
it('removes everything except letters, numbers and spaces', () => {
|
||||
expect(unDasherize('1A !"£$%^*()_+=-.b 2')).toBe('1A b 2');
|
||||
});
|
||||
it('trims off surrounding whitespace', () => {
|
||||
expect(unDasherize('--the-space--between----')).toBe('the space between');
|
||||
});
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
function dasherize(name: string): string {
|
||||
return ('' + name)
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s|\./g, '-')
|
||||
.replace(/[^a-z\d\-.]/g, '');
|
||||
}
|
||||
|
||||
function nameify(str: string): string {
|
||||
return ('' + str).replace(/[^a-z\d\s]/gi, '');
|
||||
}
|
||||
|
||||
function unDasherize(name: string): string {
|
||||
return (
|
||||
('' + name)
|
||||
// replace dash with space
|
||||
.replace(/-/g, ' ')
|
||||
// strip nonalphanumarics chars except whitespace
|
||||
.replace(/[^a-z\d\s]/gi, '')
|
||||
.trim()
|
||||
);
|
||||
}
|
||||
|
||||
export { dasherize, nameify, unDasherize };
|
||||
Reference in New Issue
Block a user