fix(i18n): pathPrefix for languages at subpath

This commit is contained in:
Mrugesh Mohapatra
2020-12-18 01:14:23 +05:30
parent ac6fc605ad
commit a3b1b52cdd
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,10 @@
const path = require('path'); const path = require('path');
const config = require('./config/env');
const {
clientLocale,
curriculumLocale,
homeLocation
} = require('../config/env');
const { const {
buildChallenges, buildChallenges,
replaceChallengeNode, replaceChallengeNode,
@ -8,12 +12,17 @@ const {
} = require('./utils/buildChallenges'); } = require('./utils/buildChallenges');
const curriculumIntroRoot = path.resolve(__dirname, './src/pages'); const curriculumIntroRoot = path.resolve(__dirname, './src/pages');
const pathPrefix =
clientLocale === 'english' || clientLocale === 'chinese'
? ''
: '/' + clientLocale;
module.exports = { module.exports = {
siteMetadata: { siteMetadata: {
title: 'freeCodeCamp', title: 'freeCodeCamp',
siteUrl: config.homeLocation siteUrl: homeLocation
}, },
pathPrefix: pathPrefix,
plugins: [ plugins: [
'gatsby-plugin-react-helmet', 'gatsby-plugin-react-helmet',
'gatsby-plugin-postcss', 'gatsby-plugin-postcss',
@ -34,7 +43,7 @@ module.exports = {
options: { options: {
name: 'challenges', name: 'challenges',
source: buildChallenges, source: buildChallenges,
onSourceChange: replaceChallengeNode(config.curriculumLocale), onSourceChange: replaceChallengeNode(curriculumLocale),
curriculumPath: localeChallengesRootDir curriculumPath: localeChallengesRootDir
} }
}, },

View File

@ -85,7 +85,7 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"prebuild": "echo 'Client workers building...' && npm run build:workers && echo 'Client workers ready.' && node ../tools/scripts/build/ensure-env.js", "prebuild": "echo 'Client workers building...' && npm run build:workers && echo 'Client workers ready.' && node ../tools/scripts/build/ensure-env.js",
"build": "node --max_old_space_size=7168 node_modules/gatsby-cli build", "build": "node --max_old_space_size=7168 node_modules/gatsby-cli build --prefix-paths",
"build:workers": "node --max_old_space_size=7168 node_modules/webpack-cli --env.production --config ./webpack-workers.js && echo", "build:workers": "node --max_old_space_size=7168 node_modules/webpack-cli --env.production --config ./webpack-workers.js && echo",
"build:workers:debug": "node --max_old_space_size=7168 node_modules/webpack-cli --env.production --config ./webpack-workers.js --progress", "build:workers:debug": "node --max_old_space_size=7168 node_modules/webpack-cli --env.production --config ./webpack-workers.js --progress",
"clean": "gatsby clean", "clean": "gatsby clean",