refactor: use dashedName over dasherize(title)

This commit is contained in:
Oliver Eyton-Williams
2020-10-01 15:07:03 +02:00
committed by Mrugesh Mohapatra
parent d90f84e968
commit ed2840cb1c
3 changed files with 6 additions and 7 deletions

View File

@ -19,10 +19,10 @@ const createByIdentityMap = {
exports.onCreateNode = function onCreateNode({ node, actions, getNode }) {
const { createNodeField } = actions;
if (node.internal.type === 'ChallengeNode') {
const { tests = [], block, title, superBlock } = node;
const { tests = [], block, dashedName, superBlock } = node;
const slug = `/learn/${dasherize(superBlock)}/${dasherize(
block
)}/${dasherize(title)}`;
)}/${dashedName}`;
createNodeField({ node, name: 'slug', value: slug });
createNodeField({ node, name: 'blockName', value: blockNameify(block) });
createNodeField({ node, name: 'tests', value: tests });

View File

@ -99,11 +99,7 @@ export class Block extends Component {
return (
<li
className={'map-challenge-title' + completedClass}
id={
challenge.title
? dasherize(challenge.title)
: dasherize(challenge.frontmatter.title)
}
id={challenge.dashedName || dasherize(challenge.frontmatter.title)}
key={'map-challenge' + challenge.fields.slug}
>
<span className='badge map-badge'>

View File

@ -192,6 +192,9 @@ export class CompletionModalInner extends Component {
if (isOpen) {
executeGA({ type: 'modal', data: '/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