fix: Update packages and fix local dev (#26907)
<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. --> - [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md). - [x] My pull request has a descriptive title (not a vague title like `Update index.md`) - [x] My pull request targets the `master` branch of freeCodeCamp.
This commit is contained in:
committed by
mrugesh mohapatra
parent
153e1c9f38
commit
7da04a348b
@ -5,13 +5,20 @@ const commonREs = require('../../utils/regEx');
|
||||
const readDir = require('../../utils/readDir');
|
||||
|
||||
const { isAStubRE } = commonREs;
|
||||
const pagesDir = path.resolve(__dirname, '../../../guide/english/');
|
||||
// default locale to english for testing
|
||||
const { NODE_ENV: env, LOCALE: locale = 'english' } = process.env;
|
||||
|
||||
const guideDir = `../../../${
|
||||
env === 'production' ? 'guide' : 'mock-guide'
|
||||
}/${locale}`;
|
||||
|
||||
const pagesDir = path.resolve(__dirname, guideDir);
|
||||
|
||||
function withGuidePrefix(str) {
|
||||
return `/guide${str}`;
|
||||
}
|
||||
|
||||
exports.createNavigationNode = node => {
|
||||
exports.createNavigationNode = function createNavigationNode(node) {
|
||||
const {
|
||||
fileAbsolutePath,
|
||||
frontmatter: { title },
|
||||
@ -21,8 +28,9 @@ exports.createNavigationNode = node => {
|
||||
|
||||
const nodeDir = fileAbsolutePath.replace(/\/index\.md$/, '');
|
||||
const dashedName = nodeDir.split('/').slice(-1)[0];
|
||||
const [, path] = nodeDir.split(pagesDir);
|
||||
const parentPath = path
|
||||
const [, nodePath] = nodeDir.split(pagesDir);
|
||||
|
||||
const parentPath = nodePath
|
||||
.split('/')
|
||||
.slice(0, -1)
|
||||
.join('/');
|
||||
@ -33,7 +41,7 @@ exports.createNavigationNode = node => {
|
||||
hasChildren: !!categoryChildren.length,
|
||||
dashedName,
|
||||
isStubbed: isAStubRE.test(content),
|
||||
path: withGuidePrefix(path),
|
||||
path: withGuidePrefix(nodePath),
|
||||
parentPath: withGuidePrefix(parentPath),
|
||||
title
|
||||
};
|
||||
|
Reference in New Issue
Block a user