@docusaurus/core 0.0.0-6111 → 0.0.0-6112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/docusaurus.mjs +14 -3
- package/lib/commands/build/build.d.ts +2 -1
- package/lib/commands/build/build.js +23 -17
- package/lib/commands/build/buildLocale.js +1 -1
- package/lib/commands/deploy.d.ts +2 -1
- package/lib/server/i18n.d.ts +1 -1
- package/lib/server/i18n.js +1 -1
- package/package.json +11 -11
package/bin/docusaurus.mjs
CHANGED
|
@@ -33,6 +33,15 @@ process.env.NODE_ENV ??= 'development';
|
|
|
33
33
|
|
|
34
34
|
await beforeCli();
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} locale
|
|
38
|
+
* @param {string[]} locales
|
|
39
|
+
* @returns {string[]}
|
|
40
|
+
*/
|
|
41
|
+
function concatLocaleOptions(locale, locales = []) {
|
|
42
|
+
return locales.concat(locale);
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
|
|
37
46
|
|
|
38
47
|
cli
|
|
@@ -55,8 +64,9 @@ cli
|
|
|
55
64
|
'path to docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
56
65
|
)
|
|
57
66
|
.option(
|
|
58
|
-
'-l, --locale <locale
|
|
59
|
-
'build the site in
|
|
67
|
+
'-l, --locale <locale...>',
|
|
68
|
+
'build the site in the specified locale(s). Build all known locales otherwise',
|
|
69
|
+
concatLocaleOptions,
|
|
60
70
|
)
|
|
61
71
|
.option(
|
|
62
72
|
'--no-minify',
|
|
@@ -101,7 +111,8 @@ cli
|
|
|
101
111
|
.description('Deploy website to GitHub pages.')
|
|
102
112
|
.option(
|
|
103
113
|
'-l, --locale <locale>',
|
|
104
|
-
'deploy the site in
|
|
114
|
+
'deploy the site in the specified locale(s). Deploy all known locales otherwise',
|
|
115
|
+
concatLocaleOptions,
|
|
105
116
|
)
|
|
106
117
|
.option(
|
|
107
118
|
'--out-dir <dir>',
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type LoadContextParams } from '../../server/site';
|
|
8
|
-
export type BuildCLIOptions = Pick<LoadContextParams, 'config' | '
|
|
8
|
+
export type BuildCLIOptions = Pick<LoadContextParams, 'config' | 'outDir'> & {
|
|
9
|
+
locale?: [string, ...string[]];
|
|
9
10
|
bundleAnalyzer?: boolean;
|
|
10
11
|
minify?: boolean;
|
|
11
12
|
dev?: boolean;
|
|
@@ -17,7 +17,7 @@ const buildLocale_1 = require("./buildLocale");
|
|
|
17
17
|
async function build(siteDirParam = '.', cliOptions = {}) {
|
|
18
18
|
process.env.BABEL_ENV = 'production';
|
|
19
19
|
process.env.NODE_ENV = 'production';
|
|
20
|
-
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
|
|
20
|
+
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale?.[0];
|
|
21
21
|
if (cliOptions.dev) {
|
|
22
22
|
logger_1.default.info `Building in dev mode`;
|
|
23
23
|
process.env.BABEL_ENV = 'development';
|
|
@@ -36,29 +36,35 @@ async function build(siteDirParam = '.', cliOptions = {}) {
|
|
|
36
36
|
}));
|
|
37
37
|
logger_1.default.info `Use code=${'npm run serve'} command to test your build locally.`;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// We need the default locale to always be the 1st in the list. If we build it
|
|
40
|
+
// last, it would "erase" the localized sites built in sub-folders
|
|
41
|
+
function orderLocales({ locales, defaultLocale, }) {
|
|
42
|
+
if (locales.includes(defaultLocale)) {
|
|
43
|
+
return [
|
|
44
|
+
defaultLocale,
|
|
45
|
+
...locales.filter((locale) => locale !== defaultLocale),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return locales;
|
|
42
50
|
}
|
|
51
|
+
}
|
|
52
|
+
async function getLocalesToBuild({ siteDir, cliOptions, }) {
|
|
53
|
+
// We disable locale path localization if CLI has single "--locale" option
|
|
54
|
+
// yarn build --locale fr => baseUrl=/ instead of baseUrl=/fr/
|
|
55
|
+
const localizePath = cliOptions.locale?.length === 1 ? false : undefined;
|
|
43
56
|
const context = await (0, site_1.loadContext)({
|
|
44
57
|
siteDir,
|
|
45
58
|
outDir: cliOptions.outDir,
|
|
46
59
|
config: cliOptions.config,
|
|
47
|
-
|
|
48
|
-
localizePath: cliOptions.locale ? false : undefined,
|
|
60
|
+
localizePath,
|
|
49
61
|
});
|
|
50
|
-
const i18n = await (0, i18n_1.loadI18n)(context.siteConfig
|
|
51
|
-
|
|
62
|
+
const i18n = await (0, i18n_1.loadI18n)(context.siteConfig);
|
|
63
|
+
const locales = cliOptions.locale ?? i18n.locales;
|
|
64
|
+
return orderLocales({
|
|
65
|
+
locales: locales,
|
|
66
|
+
defaultLocale: i18n.defaultLocale,
|
|
52
67
|
});
|
|
53
|
-
if (i18n.locales.length > 1) {
|
|
54
|
-
logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
|
|
55
|
-
}
|
|
56
|
-
// We need the default locale to always be the 1st in the list. If we build it
|
|
57
|
-
// last, it would "erase" the localized sites built in sub-folders
|
|
58
|
-
return [
|
|
59
|
-
i18n.defaultLocale,
|
|
60
|
-
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
|
|
61
|
-
];
|
|
62
68
|
}
|
|
63
69
|
async function tryToBuildLocale(params) {
|
|
64
70
|
try {
|
|
@@ -30,7 +30,7 @@ async function buildLocale({ siteDir, locale, cliOptions, }) {
|
|
|
30
30
|
outDir: cliOptions.outDir,
|
|
31
31
|
config: cliOptions.config,
|
|
32
32
|
locale,
|
|
33
|
-
localizePath: cliOptions.locale ? false : undefined,
|
|
33
|
+
localizePath: cliOptions.locale?.length === 1 ? false : undefined,
|
|
34
34
|
}));
|
|
35
35
|
const { props } = site;
|
|
36
36
|
const { outDir, plugins, siteConfig } = props;
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type LoadContextParams } from '../server/site';
|
|
8
|
-
export type DeployCLIOptions = Pick<LoadContextParams, 'config' | '
|
|
8
|
+
export type DeployCLIOptions = Pick<LoadContextParams, 'config' | 'outDir'> & {
|
|
9
|
+
locale?: [string, ...string[]];
|
|
9
10
|
skipBuild?: boolean;
|
|
10
11
|
targetDir?: string;
|
|
11
12
|
};
|
package/lib/server/i18n.d.ts
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
import type { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
|
|
8
8
|
import type { LoadContextParams } from './site';
|
|
9
9
|
export declare function getDefaultLocaleConfig(locale: string): I18nLocaleConfig;
|
|
10
|
-
export declare function loadI18n(config: DocusaurusConfig, options
|
|
10
|
+
export declare function loadI18n(config: DocusaurusConfig, options?: Pick<LoadContextParams, 'locale'>): Promise<I18n>;
|
package/lib/server/i18n.js
CHANGED
|
@@ -74,7 +74,7 @@ function getDefaultLocaleConfig(locale) {
|
|
|
74
74
|
}
|
|
75
75
|
async function loadI18n(config, options) {
|
|
76
76
|
const { i18n: i18nConfig } = config;
|
|
77
|
-
const currentLocale = options
|
|
77
|
+
const currentLocale = options?.locale ?? i18nConfig.defaultLocale;
|
|
78
78
|
if (!i18nConfig.locales.includes(currentLocale)) {
|
|
79
79
|
logger_1.default.warn `The locale name=${currentLocale} was not found in your site configuration: Available locales are: ${i18nConfig.locales}
|
|
80
80
|
Note: Docusaurus only support running one locale at a time.`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-6112",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "0.0.0-
|
|
37
|
-
"@docusaurus/bundler": "0.0.0-
|
|
38
|
-
"@docusaurus/logger": "0.0.0-
|
|
39
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
40
|
-
"@docusaurus/utils": "0.0.0-
|
|
41
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
42
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
36
|
+
"@docusaurus/babel": "0.0.0-6112",
|
|
37
|
+
"@docusaurus/bundler": "0.0.0-6112",
|
|
38
|
+
"@docusaurus/logger": "0.0.0-6112",
|
|
39
|
+
"@docusaurus/mdx-loader": "0.0.0-6112",
|
|
40
|
+
"@docusaurus/utils": "0.0.0-6112",
|
|
41
|
+
"@docusaurus/utils-common": "0.0.0-6112",
|
|
42
|
+
"@docusaurus/utils-validation": "0.0.0-6112",
|
|
43
43
|
"boxen": "^6.2.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"webpack-merge": "^6.0.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
82
|
-
"@docusaurus/types": "0.0.0-
|
|
81
|
+
"@docusaurus/module-type-aliases": "0.0.0-6112",
|
|
82
|
+
"@docusaurus/types": "0.0.0-6112",
|
|
83
83
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
84
84
|
"@types/detect-port": "^1.3.3",
|
|
85
85
|
"@types/react-dom": "^18.2.7",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=18.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "dd7a8f35cefc9d93e08d19e6959c45c41a811739"
|
|
104
104
|
}
|