refactor: use dashedName over dasherize(title)
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
d90f84e968
commit
ed2840cb1c
@ -19,10 +19,10 @@ const createByIdentityMap = {
|
|||||||
exports.onCreateNode = function onCreateNode({ node, actions, getNode }) {
|
exports.onCreateNode = function onCreateNode({ node, actions, getNode }) {
|
||||||
const { createNodeField } = actions;
|
const { createNodeField } = actions;
|
||||||
if (node.internal.type === 'ChallengeNode') {
|
if (node.internal.type === 'ChallengeNode') {
|
||||||
const { tests = [], block, title, superBlock } = node;
|
const { tests = [], block, dashedName, superBlock } = node;
|
||||||
const slug = `/learn/${dasherize(superBlock)}/${dasherize(
|
const slug = `/learn/${dasherize(superBlock)}/${dasherize(
|
||||||
block
|
block
|
||||||
)}/${dasherize(title)}`;
|
)}/${dashedName}`;
|
||||||
createNodeField({ node, name: 'slug', value: slug });
|
createNodeField({ node, name: 'slug', value: slug });
|
||||||
createNodeField({ node, name: 'blockName', value: blockNameify(block) });
|
createNodeField({ node, name: 'blockName', value: blockNameify(block) });
|
||||||
createNodeField({ node, name: 'tests', value: tests });
|
createNodeField({ node, name: 'tests', value: tests });
|
||||||
|
@ -99,11 +99,7 @@ export class Block extends Component {
|
|||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
className={'map-challenge-title' + completedClass}
|
className={'map-challenge-title' + completedClass}
|
||||||
id={
|
id={challenge.dashedName || dasherize(challenge.frontmatter.title)}
|
||||||
challenge.title
|
|
||||||
? dasherize(challenge.title)
|
|
||||||
: dasherize(challenge.frontmatter.title)
|
|
||||||
}
|
|
||||||
key={'map-challenge' + challenge.fields.slug}
|
key={'map-challenge' + challenge.fields.slug}
|
||||||
>
|
>
|
||||||
<span className='badge map-badge'>
|
<span className='badge map-badge'>
|
||||||
|
@ -192,6 +192,9 @@ export class CompletionModalInner extends Component {
|
|||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
executeGA({ type: 'modal', data: '/completion-modal' });
|
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);
|
const dashedName = dasherize(title);
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
Reference in New Issue
Block a user