feat(guide): add footer link to article source on GitHub

fix/suggested-changes
This commit is contained in:
moT01
2019-03-11 08:38:38 -05:00
committed by mrugesh mohapatra
parent 24802779be
commit ebe420c099
4 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
exports.getGithubPath = function getGithubPath(fileAbsolutePath) {
const { NODE_ENV: env } = process.env;
const guideType = env === 'production' ? 'guide' : 'mock-guide';
let githubFilePath =
'https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md#research-write-and-update-our-guide-articles';
const pathIndex = fileAbsolutePath.indexOf(`/${guideType}`);
if (pathIndex > -1) {
const newPath = fileAbsolutePath.slice(pathIndex);
githubFilePath = `https://github.com/freeCodeCamp/freeCodeCamp/blob/master${newPath}`;
}
return githubFilePath;
};