From ed2840cb1c3e3fe1f430be1484affd43b99de5f3 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 1 Oct 2020 15:07:03 +0200 Subject: [PATCH] refactor: use dashedName over dasherize(title) --- client/gatsby-node.js | 4 ++-- client/src/components/Map/components/Block.js | 6 +----- .../src/templates/Challenges/components/CompletionModal.js | 3 +++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/gatsby-node.js b/client/gatsby-node.js index 9e8e0c80cc..b86ff00607 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -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 }); diff --git a/client/src/components/Map/components/Block.js b/client/src/components/Map/components/Block.js index 12e23ab9eb..c8ec4d5967 100644 --- a/client/src/components/Map/components/Block.js +++ b/client/src/components/Map/components/Block.js @@ -99,11 +99,7 @@ export class Block extends Component { return (
  • diff --git a/client/src/templates/Challenges/components/CompletionModal.js b/client/src/templates/Challenges/components/CompletionModal.js index 97808be640..16d0ef4b22 100644 --- a/client/src/templates/Challenges/components/CompletionModal.js +++ b/client/src/templates/Challenges/components/CompletionModal.js @@ -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 (