From 16551d2ad6e2f097eea1cef4722e637bf673d8ad Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Fri, 2 Aug 2019 01:13:18 +0530 Subject: [PATCH] fix: create links to forumTopicIds or search --- client/src/templates/Challenges/classic/Show.js | 9 +++++---- client/src/templates/Challenges/utils/index.js | 8 ++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/client/src/templates/Challenges/classic/Show.js b/client/src/templates/Challenges/classic/Show.js index be344e7d64..80f3ed3621 100644 --- a/client/src/templates/Challenges/classic/Show.js +++ b/client/src/templates/Challenges/classic/Show.js @@ -167,10 +167,10 @@ class ShowClassic extends Component { } getGuideUrl() { - const { - fields: { slug } - } = this.getChallenge(); - return createGuideUrl(slug); + const { forumTopicId, title } = this.getChallenge(); + return forumTopicId + ? 'https://www.freecodecamp.org/forum/t/' + forumTopicId + : createGuideUrl(title); } getVideoUrl = () => this.getChallenge().videoUrl; @@ -303,6 +303,7 @@ export const query = graphql` instructions challengeType videoUrl + forumTopicId fields { slug blockName diff --git a/client/src/templates/Challenges/utils/index.js b/client/src/templates/Challenges/utils/index.js index fd2837161d..3d87cbd444 100644 --- a/client/src/templates/Challenges/utils/index.js +++ b/client/src/templates/Challenges/utils/index.js @@ -1,11 +1,7 @@ const guideBase = 'https://www.freecodecamp.org/forum/search?q='; -export function createGuideUrl(slug = '') { - return ( - guideBase + - slug.substring(slug.lastIndexOf('/') + 1) + - '%20%40camperbot%20%23guide' - ); +export function createGuideUrl(title = '') { + return guideBase + title + '%20in%3Atitle%20order%3Aviews'; } export function isGoodXHRStatus(status) {