fix: create links to forumTopicIds or search

This commit is contained in:
Mrugesh Mohapatra
2019-08-02 01:13:18 +05:30
committed by mrugesh
parent 31f337f2bd
commit 16551d2ad6
2 changed files with 7 additions and 10 deletions

View File

@ -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

View File

@ -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) {