refactor: simplify challenge.block usage (#41185)

This commit is contained in:
Oliver Eyton-Williams
2021-02-23 05:22:48 +01:00
committed by GitHub
parent 3dd33d87ed
commit f8699a8d55
14 changed files with 32 additions and 47 deletions

View File

@ -3,7 +3,6 @@ const env = require('../config/env');
const { createFilePath } = require('gatsby-source-filesystem');
const uniq = require('lodash/uniq');
const { dasherize } = require('../utils/slugs');
const { blockNameify } = require('../utils/block-nameify');
const {
createChallengePages,
@ -20,7 +19,7 @@ exports.onCreateNode = function onCreateNode({ node, actions, getNode }) {
const { createNodeField } = actions;
if (node.internal.type === 'ChallengeNode') {
const { tests = [], block, dashedName, superBlock } = node;
const slug = `/learn/${superBlock}/${dasherize(block)}/${dashedName}`;
const slug = `/learn/${superBlock}/${block}/${dashedName}`;
createNodeField({ node, name: 'slug', value: slug });
createNodeField({ node, name: 'blockName', value: blockNameify(block) });
createNodeField({ node, name: 'tests', value: tests });