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
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ describe('fcc-create-nav-data', () => {
|
||||
},
|
||||
fileAbsolutePath: path.resolve(
|
||||
__dirname,
|
||||
'../../../guide/english/php/functions/files/file-writing/index.md'
|
||||
'../../../mock-guide/english/php/functions/files/file-writing/index.md'
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,21 @@
|
||||
const { createNavigationNode } = require('./create-navigation-node');
|
||||
|
||||
exports.onCreateNode = ({ actions, node }) => {
|
||||
const { internal: {type, identity}} = node;
|
||||
if (type === 'MarkdownRemark' && identity === 'guideMarkdown') {
|
||||
exports.onCreateNode = function createNavDataOnCreateNode({ actions, node }) {
|
||||
const {
|
||||
internal: { type },
|
||||
fields
|
||||
} = node;
|
||||
if (
|
||||
type === 'MarkdownRemark' &&
|
||||
fields &&
|
||||
fields.nodeIdentity === 'guideMarkdown'
|
||||
) {
|
||||
if (node.fileAbsolutePath.includes('LICENSE.md')) {
|
||||
return null;
|
||||
}
|
||||
const { createNode } = actions;
|
||||
return Promise.resolve(createNavigationNode(node)).then(createNode);
|
||||
const navNode = createNavigationNode(node);
|
||||
return createNode(navNode);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
@ -1,6 +1,9 @@
|
||||
const { createChallengeNodes } = require('./create-Challenge-nodes');
|
||||
|
||||
exports.sourceNodes = ({ actions, reporter }, pluginOptions) => {
|
||||
exports.sourceNodes = function sourceChallengesSourceNodes(
|
||||
{ actions, reporter },
|
||||
pluginOptions
|
||||
) {
|
||||
if (typeof pluginOptions.source !== 'function') {
|
||||
reporter.panic(`
|
||||
"source" is a required option for fcc-source-challenges. It must be a function
|
||||
|
@ -19,12 +19,11 @@ function markdownToHTML(node) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ({ markdownAST }) => {
|
||||
visit(markdownAST, 'image', imageNode => {
|
||||
if (emojiRE.test(imageNode.title)) {
|
||||
return markdownToHTML(imageNode);
|
||||
}
|
||||
|
||||
return imageNode;
|
||||
});
|
||||
module.exports = function forumEmojiPlugin({ markdownAST }) {
|
||||
visit(
|
||||
markdownAST,
|
||||
'image',
|
||||
imageNode =>
|
||||
emojiRE.test(imageNode.title) ? markdownToHTML(imageNode) : imageNode
|
||||
);
|
||||
};
|
||||
|
@ -1,4 +1,7 @@
|
||||
exports.onCreateNode = ({ node, reporter }, { predicate, identity }) => {
|
||||
exports.onCreateNode = function remarkNodeIdentityOnCreateNode(
|
||||
{ node, reporter, actions },
|
||||
{ predicate, identity }
|
||||
) {
|
||||
if (typeof predicate !== 'function') {
|
||||
reporter.panic(
|
||||
'Please supply a predicate function to `gatsby-plugin-identity`'
|
||||
@ -10,7 +13,9 @@ exports.onCreateNode = ({ node, reporter }, { predicate, identity }) => {
|
||||
'that match the predicate'
|
||||
);
|
||||
}
|
||||
const { createNodeField } = actions;
|
||||
if (predicate(node)) {
|
||||
node.internal.identity = identity;
|
||||
createNodeField({ node, name: 'nodeIdentity', value: identity });
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
Reference in New Issue
Block a user