-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow customizing localization path of each locale (#7624)
- Loading branch information
Showing
24 changed files
with
254 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
...s-plugin-content-docs/src/__tests__/__fixtures__/site-with-custom-i18n-path/sidebars.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.73 KB
(120%)
packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site/docusaurus.config.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
packages/docusaurus/src/server/__tests__/__snapshots__/index.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`load loads props for site with custom i18n path 1`] = ` | ||
{ | ||
"baseUrl": "/", | ||
"codeTranslations": {}, | ||
"generatedFilesDir": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site/.docusaurus", | ||
"headTags": "", | ||
"i18n": { | ||
"currentLocale": "en", | ||
"defaultLocale": "en", | ||
"localeConfigs": { | ||
"en": { | ||
"calendar": "gregory", | ||
"direction": "ltr", | ||
"htmlLang": "en", | ||
"label": "English", | ||
"path": "en-custom", | ||
}, | ||
"zh-Hans": { | ||
"calendar": "gregory", | ||
"direction": "ltr", | ||
"htmlLang": "zh-Hans", | ||
"label": "简体中文", | ||
"path": "zh-Hans-custom", | ||
}, | ||
}, | ||
"locales": [ | ||
"en", | ||
"zh-Hans", | ||
], | ||
"path": "i18n", | ||
}, | ||
"localizationDir": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site/i18n/en-custom", | ||
"outDir": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site/build", | ||
"plugins": [ | ||
{ | ||
"content": undefined, | ||
"getClientModules": [Function], | ||
"injectHtmlTags": [Function], | ||
"name": "docusaurus-bootstrap-plugin", | ||
"options": { | ||
"id": "default", | ||
}, | ||
"path": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site", | ||
"version": { | ||
"type": "synthetic", | ||
}, | ||
}, | ||
{ | ||
"configureWebpack": [Function], | ||
"content": undefined, | ||
"name": "docusaurus-mdx-fallback-plugin", | ||
"options": { | ||
"id": "default", | ||
}, | ||
"path": ".", | ||
"version": { | ||
"type": "synthetic", | ||
}, | ||
}, | ||
], | ||
"postBodyTags": "", | ||
"preBodyTags": "", | ||
"routes": [], | ||
"routesPaths": [ | ||
"/404.html", | ||
], | ||
"siteConfig": { | ||
"baseUrl": "/", | ||
"baseUrlIssueBanner": true, | ||
"clientModules": [], | ||
"customFields": {}, | ||
"i18n": { | ||
"defaultLocale": "en", | ||
"localeConfigs": { | ||
"en": { | ||
"direction": "ltr", | ||
"path": "en-custom", | ||
}, | ||
"zh-Hans": { | ||
"direction": "ltr", | ||
"path": "zh-Hans-custom", | ||
}, | ||
}, | ||
"locales": [ | ||
"en", | ||
"zh-Hans", | ||
], | ||
"path": "i18n", | ||
}, | ||
"noIndex": false, | ||
"onBrokenLinks": "throw", | ||
"onBrokenMarkdownLinks": "warn", | ||
"onDuplicateRoutes": "warn", | ||
"plugins": [], | ||
"presets": [], | ||
"scripts": [], | ||
"staticDirectories": [ | ||
"static", | ||
], | ||
"stylesheets": [], | ||
"tagline": "", | ||
"themeConfig": {}, | ||
"themes": [], | ||
"title": "Site", | ||
"titleDelimiter": "|", | ||
"url": "https://example.com", | ||
}, | ||
"siteConfigPath": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site/docusaurus.config.js", | ||
"siteDir": "<PROJECT_ROOT>/packages/docusaurus/src/server/__tests__/__fixtures__/custom-i18n-site", | ||
"siteMetadata": { | ||
"docusaurusVersion": "<CURRENT_VERSION>", | ||
"pluginVersions": {}, | ||
"siteVersion": undefined, | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import path from 'path'; | ||
import {mergeWithCustomize} from 'webpack-merge'; | ||
import {loadSetup} from './testUtils'; | ||
import type {Props} from '@docusaurus/types'; | ||
import type {DeepPartial} from 'utility-types'; | ||
|
||
describe('load', () => { | ||
it('loads props for site with custom i18n path', async () => { | ||
const props = await loadSetup('custom-i18n-site'); | ||
expect(props).toMatchSnapshot(); | ||
const props2 = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'}); | ||
expect(props2).toEqual( | ||
mergeWithCustomize<DeepPartial<Props>>({ | ||
customizeArray(a, b, key) { | ||
return ['routesPaths', 'plugins'].includes(key) ? b : undefined; | ||
}, | ||
})(props, { | ||
baseUrl: '/zh-Hans/', | ||
i18n: { | ||
currentLocale: 'zh-Hans', | ||
}, | ||
localizationDir: path.join( | ||
__dirname, | ||
'__fixtures__/custom-i18n-site/i18n/zh-Hans-custom', | ||
), | ||
outDir: path.join( | ||
__dirname, | ||
'__fixtures__/custom-i18n-site/build/zh-Hans', | ||
), | ||
routesPaths: ['/zh-Hans/404.html'], | ||
siteConfig: { | ||
baseUrl: '/zh-Hans/', | ||
}, | ||
plugins: props2.plugins, | ||
}), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.