@docusaurus/core 0.0.0-4721 → 0.0.0-4724
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/beforeCli.mjs +1 -3
- package/lib/commands/deploy.d.ts +0 -3
- package/lib/commands/deploy.js +4 -31
- package/lib/commands/start.js +1 -1
- package/lib/commands/writeHeadingIds.d.ts +2 -7
- package/lib/commands/writeHeadingIds.js +2 -53
- package/lib/server/configValidation.js +1 -1
- package/lib/server/i18n.d.ts +1 -1
- package/lib/server/i18n.js +2 -6
- package/lib/server/index.js +9 -12
- package/lib/server/plugins/index.js +2 -2
- package/lib/server/routes.js +20 -6
- package/lib/server/themes/index.js +1 -1
- package/lib/server/translations/translations.d.ts +0 -9
- package/lib/server/translations/translations.js +1 -6
- package/package.json +16 -16
package/bin/beforeCli.mjs
CHANGED
|
@@ -98,9 +98,7 @@ export default async function beforeCli() {
|
|
|
98
98
|
.filter((p) => p.startsWith('@docusaurus'))
|
|
99
99
|
.map((p) => p.concat('@latest'))
|
|
100
100
|
.join(' ');
|
|
101
|
-
const isYarnUsed = await fs.pathExists(
|
|
102
|
-
path.resolve(process.cwd(), 'yarn.lock'),
|
|
103
|
-
);
|
|
101
|
+
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
|
|
104
102
|
const upgradeCommand = isYarnUsed
|
|
105
103
|
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
106
104
|
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
package/lib/commands/deploy.d.ts
CHANGED
|
@@ -5,7 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { BuildCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export declare function buildSshUrl(githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
|
|
9
|
-
export declare function buildHttpsUrl(gitCredentials: string, githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
|
|
10
|
-
export declare function hasSSHProtocol(sourceRepoUrl: string): boolean;
|
|
11
8
|
export default function deploy(siteDir: string, cliOptions?: Partial<BuildCLIOptions>): Promise<void>;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.hasSSHProtocol = exports.buildHttpsUrl = exports.buildSshUrl = void 0;
|
|
10
9
|
const tslib_1 = require("tslib");
|
|
11
10
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
11
|
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
|
|
13
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
|
+
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
const server_1 = require("../server");
|
|
15
15
|
const build_1 = tslib_1.__importDefault(require("./build"));
|
|
16
16
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -33,33 +33,6 @@ function shellExecLog(cmd) {
|
|
|
33
33
|
throw err;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function buildSshUrl(githubHost, organizationName, projectName, githubPort) {
|
|
37
|
-
if (githubPort) {
|
|
38
|
-
return `ssh://git@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
|
|
39
|
-
}
|
|
40
|
-
return `git@${githubHost}:${organizationName}/${projectName}.git`;
|
|
41
|
-
}
|
|
42
|
-
exports.buildSshUrl = buildSshUrl;
|
|
43
|
-
function buildHttpsUrl(gitCredentials, githubHost, organizationName, projectName, githubPort) {
|
|
44
|
-
if (githubPort) {
|
|
45
|
-
return `https://${gitCredentials}@${githubHost}:${githubPort}/${organizationName}/${projectName}.git`;
|
|
46
|
-
}
|
|
47
|
-
return `https://${gitCredentials}@${githubHost}/${organizationName}/${projectName}.git`;
|
|
48
|
-
}
|
|
49
|
-
exports.buildHttpsUrl = buildHttpsUrl;
|
|
50
|
-
function hasSSHProtocol(sourceRepoUrl) {
|
|
51
|
-
try {
|
|
52
|
-
if (new URL(sourceRepoUrl).protocol === 'ssh:') {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// Fails when there isn't a protocol
|
|
59
|
-
return /^(?:[\w-]+@)?[\w.-]+:[\w./-]+/.test(sourceRepoUrl); // git@github.com:facebook/docusaurus.git
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.hasSSHProtocol = hasSSHProtocol;
|
|
63
36
|
async function deploy(siteDir, cliOptions = {}) {
|
|
64
37
|
const { outDir, siteConfig, siteConfigPath } = await (0, server_1.loadContext)(siteDir, {
|
|
65
38
|
customConfigFilePath: cliOptions.config,
|
|
@@ -87,7 +60,7 @@ This behavior can have SEO impacts and create relative link issues.
|
|
|
87
60
|
process.env.USE_SSH.toLowerCase() === 'true';
|
|
88
61
|
if (!gitUser && !useSSH) {
|
|
89
62
|
// If USE_SSH is unspecified: try inferring from repo URL
|
|
90
|
-
if (process.env.USE_SSH === undefined && hasSSHProtocol(sourceRepoUrl)) {
|
|
63
|
+
if (process.env.USE_SSH === undefined && (0, utils_1.hasSSHProtocol)(sourceRepoUrl)) {
|
|
91
64
|
useSSH = true;
|
|
92
65
|
}
|
|
93
66
|
else {
|
|
@@ -132,12 +105,12 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
132
105
|
const githubPort = process.env.GITHUB_PORT || siteConfig.githubPort;
|
|
133
106
|
let deploymentRepoURL;
|
|
134
107
|
if (useSSH) {
|
|
135
|
-
deploymentRepoURL = buildSshUrl(githubHost, organizationName, projectName, githubPort);
|
|
108
|
+
deploymentRepoURL = (0, utils_1.buildSshUrl)(githubHost, organizationName, projectName, githubPort);
|
|
136
109
|
}
|
|
137
110
|
else {
|
|
138
111
|
const gitPass = process.env.GIT_PASS;
|
|
139
112
|
const gitCredentials = gitPass ? `${gitUser}:${gitPass}` : gitUser;
|
|
140
|
-
deploymentRepoURL = buildHttpsUrl(gitCredentials, githubHost, organizationName, projectName, githubPort);
|
|
113
|
+
deploymentRepoURL = (0, utils_1.buildHttpsUrl)(gitCredentials, githubHost, organizationName, projectName, githubPort);
|
|
141
114
|
}
|
|
142
115
|
logger_1.default.info `Remote repo URL: name=${obfuscateGitPass(deploymentRepoURL)}`;
|
|
143
116
|
// Check if this is a cross-repo publish.
|
package/lib/commands/start.js
CHANGED
|
@@ -100,7 +100,7 @@ async function start(siteDir, cliOptions) {
|
|
|
100
100
|
plugins: [
|
|
101
101
|
// Generates an `index.html` file with the <script> injected.
|
|
102
102
|
new html_webpack_plugin_1.default({
|
|
103
|
-
template: path_1.default.
|
|
103
|
+
template: path_1.default.join(__dirname, '../webpack/templates/index.html.template.ejs'),
|
|
104
104
|
// So we can define the position where the scripts are injected.
|
|
105
105
|
inject: false,
|
|
106
106
|
filename: 'index.html',
|
|
@@ -4,10 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
overwrite?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare function transformMarkdownContent(content: string, options?: Options): string;
|
|
12
|
-
export default function writeHeadingIds(siteDir: string, files?: string[], options?: Options): Promise<void>;
|
|
13
|
-
export {};
|
|
7
|
+
import { type WriteHeadingIDOptions } from '@docusaurus/utils';
|
|
8
|
+
export default function writeHeadingIds(siteDir: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
|
|
@@ -6,67 +6,16 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.transformMarkdownContent = void 0;
|
|
10
9
|
const tslib_1 = require("tslib");
|
|
11
10
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
11
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
|
+
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
const server_1 = require("../server");
|
|
14
14
|
const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
|
|
15
|
-
const utils_1 = require("@docusaurus/utils");
|
|
16
15
|
const utils_2 = require("../server/utils");
|
|
17
|
-
function unwrapMarkdownLinks(line) {
|
|
18
|
-
return line.replace(/\[(?<alt>[^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
|
|
19
|
-
}
|
|
20
|
-
function addHeadingId(line, slugger, maintainCase) {
|
|
21
|
-
let headingLevel = 0;
|
|
22
|
-
while (line.charAt(headingLevel) === '#') {
|
|
23
|
-
headingLevel += 1;
|
|
24
|
-
}
|
|
25
|
-
const headingText = line.slice(headingLevel).trimEnd();
|
|
26
|
-
const headingHashes = line.slice(0, headingLevel);
|
|
27
|
-
const slug = slugger.slug(unwrapMarkdownLinks(headingText).trim(), {
|
|
28
|
-
maintainCase,
|
|
29
|
-
});
|
|
30
|
-
return `${headingHashes}${headingText} {#${slug}}`;
|
|
31
|
-
}
|
|
32
|
-
function transformMarkdownContent(content, options = { maintainCase: false, overwrite: false }) {
|
|
33
|
-
const { maintainCase = false, overwrite = false } = options;
|
|
34
|
-
const lines = content.split('\n');
|
|
35
|
-
const slugger = (0, utils_1.createSlugger)();
|
|
36
|
-
// If we can't overwrite existing slugs, make sure other headings don't
|
|
37
|
-
// generate colliding slugs by first marking these slugs as occupied
|
|
38
|
-
if (!overwrite) {
|
|
39
|
-
lines.forEach((line) => {
|
|
40
|
-
const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(line);
|
|
41
|
-
if (parsedHeading.id) {
|
|
42
|
-
slugger.slug(parsedHeading.id);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
let inCode = false;
|
|
47
|
-
return lines
|
|
48
|
-
.map((line) => {
|
|
49
|
-
if (line.startsWith('```')) {
|
|
50
|
-
inCode = !inCode;
|
|
51
|
-
return line;
|
|
52
|
-
}
|
|
53
|
-
// Ignore h1 headings, as we don't create anchor links for those
|
|
54
|
-
if (inCode || !line.startsWith('##')) {
|
|
55
|
-
return line;
|
|
56
|
-
}
|
|
57
|
-
const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(line);
|
|
58
|
-
// Do not process if id is already there
|
|
59
|
-
if (parsedHeading.id && !overwrite) {
|
|
60
|
-
return line;
|
|
61
|
-
}
|
|
62
|
-
return addHeadingId(parsedHeading.text, slugger, maintainCase);
|
|
63
|
-
})
|
|
64
|
-
.join('\n');
|
|
65
|
-
}
|
|
66
|
-
exports.transformMarkdownContent = transformMarkdownContent;
|
|
67
16
|
async function transformMarkdownFile(filepath, options) {
|
|
68
17
|
const content = await fs_extra_1.default.readFile(filepath, 'utf8');
|
|
69
|
-
const updatedContent =
|
|
18
|
+
const updatedContent = (0, utils_1.writeMarkdownHeadingId)(content, options);
|
|
70
19
|
if (content !== updatedContent) {
|
|
71
20
|
await fs_extra_1.default.writeFile(filepath, updatedContent);
|
|
72
21
|
return filepath;
|
|
@@ -34,7 +34,7 @@ exports.DEFAULT_CONFIG = {
|
|
|
34
34
|
baseUrlIssueBanner: true,
|
|
35
35
|
staticDirectories: [utils_1.STATIC_DIR_NAME],
|
|
36
36
|
};
|
|
37
|
-
function createPluginSchema(theme
|
|
37
|
+
function createPluginSchema(theme) {
|
|
38
38
|
return (utils_validation_1.Joi.alternatives()
|
|
39
39
|
.try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array()
|
|
40
40
|
.ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required())
|
package/lib/server/i18n.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
|
|
8
8
|
export declare function getDefaultLocaleConfig(locale: string): I18nLocaleConfig;
|
|
9
|
-
export declare function loadI18n(config: DocusaurusConfig, options
|
|
9
|
+
export declare function loadI18n(config: DocusaurusConfig, options: {
|
|
10
10
|
locale?: string;
|
|
11
11
|
}): Promise<I18n>;
|
|
12
12
|
export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
|
package/lib/server/i18n.js
CHANGED
|
@@ -24,7 +24,7 @@ function getDefaultLocaleConfig(locale) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
|
|
27
|
-
async function loadI18n(config, options
|
|
27
|
+
async function loadI18n(config, options) {
|
|
28
28
|
const { i18n: i18nConfig } = config;
|
|
29
29
|
const currentLocale = options.locale ?? i18nConfig.defaultLocale;
|
|
30
30
|
if (!i18nConfig.locales.includes(currentLocale)) {
|
|
@@ -61,10 +61,6 @@ function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
|
|
|
61
61
|
return path_1.default.join(originalPath, i18n.currentLocale);
|
|
62
62
|
}
|
|
63
63
|
// Url paths; add a trailing slash so it's a valid base URL
|
|
64
|
-
|
|
65
|
-
return (0, utils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
|
|
66
|
-
}
|
|
67
|
-
// should never happen
|
|
68
|
-
throw new Error(`Unhandled path type "${pathType}".`);
|
|
64
|
+
return (0, utils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
|
|
69
65
|
}
|
|
70
66
|
exports.localizePath = localizePath;
|
package/lib/server/index.js
CHANGED
|
@@ -27,27 +27,20 @@ const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions
|
|
|
27
27
|
const module_1 = require("module");
|
|
28
28
|
const moduleShorthand_1 = require("./moduleShorthand");
|
|
29
29
|
async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
30
|
-
const
|
|
31
|
-
const siteConfigPath = path_1.default.isAbsolute(siteConfigPathUnresolved)
|
|
32
|
-
? siteConfigPathUnresolved
|
|
33
|
-
: path_1.default.resolve(siteDir, siteConfigPathUnresolved);
|
|
30
|
+
const siteConfigPath = path_1.default.resolve(siteDir, customConfigFilePath ?? utils_1.DEFAULT_CONFIG_FILE_NAME);
|
|
34
31
|
const siteConfig = await (0, config_1.default)(siteConfigPath);
|
|
35
32
|
return { siteConfig, siteConfigPath };
|
|
36
33
|
}
|
|
37
34
|
exports.loadSiteConfig = loadSiteConfig;
|
|
38
35
|
async function loadContext(siteDir, options = {}) {
|
|
39
36
|
const { customOutDir, locale, customConfigFilePath } = options;
|
|
40
|
-
const generatedFilesDir = path_1.default.
|
|
41
|
-
? utils_1.GENERATED_FILES_DIR_NAME
|
|
42
|
-
: path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
|
|
37
|
+
const generatedFilesDir = path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
|
|
43
38
|
const { siteConfig: initialSiteConfig, siteConfigPath } = await loadSiteConfig({
|
|
44
39
|
siteDir,
|
|
45
40
|
customConfigFilePath,
|
|
46
41
|
});
|
|
47
42
|
const { ssrTemplate } = initialSiteConfig;
|
|
48
|
-
const baseOutDir = customOutDir
|
|
49
|
-
? path_1.default.resolve(customOutDir)
|
|
50
|
-
: path_1.default.resolve(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME);
|
|
43
|
+
const baseOutDir = path_1.default.resolve(siteDir, customOutDir ?? utils_1.DEFAULT_BUILD_DIR_NAME);
|
|
51
44
|
const i18n = await (0, i18n_1.loadI18n)(initialSiteConfig, { locale });
|
|
52
45
|
const baseUrl = (0, i18n_1.localizePath)({
|
|
53
46
|
path: initialSiteConfig.baseUrl,
|
|
@@ -119,7 +112,9 @@ function createBootstrapPlugin({ siteConfig, }) {
|
|
|
119
112
|
return {
|
|
120
113
|
name: 'docusaurus-bootstrap-plugin',
|
|
121
114
|
content: null,
|
|
122
|
-
options: {
|
|
115
|
+
options: {
|
|
116
|
+
id: 'default',
|
|
117
|
+
},
|
|
123
118
|
version: { type: 'synthetic' },
|
|
124
119
|
getClientModules() {
|
|
125
120
|
return siteConfigClientModules;
|
|
@@ -158,7 +153,9 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
158
153
|
return {
|
|
159
154
|
name: 'docusaurus-mdx-fallback-plugin',
|
|
160
155
|
content: null,
|
|
161
|
-
options: {
|
|
156
|
+
options: {
|
|
157
|
+
id: 'default',
|
|
158
|
+
},
|
|
162
159
|
version: { type: 'synthetic' },
|
|
163
160
|
configureWebpack(config, isServer, { getJSLoader }) {
|
|
164
161
|
// We need the mdx fallback loader to exclude files that were already
|
|
@@ -81,7 +81,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
81
81
|
const allContent = lodash_1.default.chain(loadedPlugins)
|
|
82
82
|
.groupBy((item) => item.name)
|
|
83
83
|
.mapValues((nameItems) => lodash_1.default.chain(nameItems)
|
|
84
|
-
.groupBy((item) => item.options.id
|
|
84
|
+
.groupBy((item) => item.options.id)
|
|
85
85
|
.mapValues((idItems) => idItems[0].content)
|
|
86
86
|
.value())
|
|
87
87
|
.value();
|
|
@@ -92,7 +92,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
|
|
|
92
92
|
if (!plugin.contentLoaded) {
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
const pluginId = plugin.options.id
|
|
95
|
+
const pluginId = plugin.options.id;
|
|
96
96
|
// plugins data files are namespaced by pluginName/pluginId
|
|
97
97
|
const dataDirRoot = path_1.default.join(context.generatedFilesDir, plugin.name);
|
|
98
98
|
const dataDir = path_1.default.join(dataDirRoot, pluginId);
|
package/lib/server/routes.js
CHANGED
|
@@ -12,7 +12,7 @@ function indent(str) {
|
|
|
12
12
|
const spaces = ' ';
|
|
13
13
|
return `${spaces}${str.replace(/\n/g, `\n${spaces}`)}`;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
function createRouteCodeString({ routePath, routeHash, exact, subroutesCodeStrings, props, }) {
|
|
16
16
|
const parts = [
|
|
17
17
|
`path: '${routePath}'`,
|
|
18
18
|
`component: ComponentCreator('${routePath}','${routeHash}')`,
|
|
@@ -26,16 +26,30 @@ ${indent((0, utils_1.removeSuffix)(subroutesCodeStrings.join(',\n'), ',\n'))}
|
|
|
26
26
|
]`);
|
|
27
27
|
}
|
|
28
28
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
// Inspired by https://github.com/armanozak/should-quote/blob/main/packages/should-quote/src/lib/should-quote.ts
|
|
30
|
+
const shouldQuote = ((key) => {
|
|
31
|
+
// Pre-sanitation to prevent injection
|
|
32
|
+
if (/[.,;:}/\s]/.test(key)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// If this key can be used in an expression like ({a:0}).a
|
|
37
|
+
// eslint-disable-next-line no-eval
|
|
38
|
+
eval(`({${key}:0}).${key}`);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
})(propName);
|
|
45
|
+
// Escape quotes as well
|
|
46
|
+
const key = shouldQuote ? JSON.stringify(propName) : propName;
|
|
33
47
|
parts.push(`${key}: ${JSON.stringify(propValue)}`);
|
|
34
48
|
});
|
|
35
49
|
return `{
|
|
36
50
|
${indent(parts.join(',\n'))}
|
|
37
51
|
}`;
|
|
38
|
-
}
|
|
52
|
+
}
|
|
39
53
|
const NotFoundRouteCode = `{
|
|
40
54
|
path: '*',
|
|
41
55
|
component: ComponentCreator('*')
|
|
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
const alias_1 = tslib_1.__importStar(require("./alias"));
|
|
14
|
-
const ThemeFallbackDir = path_1.default.
|
|
14
|
+
const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
|
|
15
15
|
async function loadThemeAliases(themePaths, userThemePaths) {
|
|
16
16
|
const aliases = {};
|
|
17
17
|
for (const themePath of themePaths) {
|
|
@@ -13,16 +13,7 @@ declare type TranslationContext = {
|
|
|
13
13
|
siteDir: string;
|
|
14
14
|
locale: string;
|
|
15
15
|
};
|
|
16
|
-
export declare function ensureTranslationFileContent(content: unknown): asserts content is TranslationFileContent;
|
|
17
|
-
export declare function readTranslationFileContent(filePath: string): Promise<TranslationFileContent | undefined>;
|
|
18
|
-
export declare function writeTranslationFileContent({ filePath, content: newContent, options, }: {
|
|
19
|
-
filePath: string;
|
|
20
|
-
content: TranslationFileContent;
|
|
21
|
-
options?: WriteTranslationsOptions;
|
|
22
|
-
}): Promise<void>;
|
|
23
|
-
export declare function getTranslationsDirPath(context: TranslationContext): string;
|
|
24
16
|
export declare function getTranslationsLocaleDirPath(context: TranslationContext): string;
|
|
25
|
-
export declare function getCodeTranslationsFilePath(context: TranslationContext): string;
|
|
26
17
|
export declare function readCodeTranslationFileContent(context: TranslationContext): Promise<TranslationFileContent | undefined>;
|
|
27
18
|
export declare function writeCodeTranslations(context: TranslationContext, content: TranslationFileContent, options: WriteTranslationsOptions): Promise<void>;
|
|
28
19
|
export declare function writePluginTranslations({ siteDir, plugin, locale, translationFile, options, }: TranslationContext & {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.
|
|
9
|
+
exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationMessages = exports.localizePluginTranslationFile = exports.writePluginTranslations = exports.writeCodeTranslations = exports.readCodeTranslationFileContent = exports.getTranslationsLocaleDirPath = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
@@ -27,7 +27,6 @@ function ensureTranslationFileContent(content) {
|
|
|
27
27
|
convert: false,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
exports.ensureTranslationFileContent = ensureTranslationFileContent;
|
|
31
30
|
async function readTranslationFileContent(filePath) {
|
|
32
31
|
if (await fs_extra_1.default.pathExists(filePath)) {
|
|
33
32
|
try {
|
|
@@ -42,7 +41,6 @@ async function readTranslationFileContent(filePath) {
|
|
|
42
41
|
}
|
|
43
42
|
return undefined;
|
|
44
43
|
}
|
|
45
|
-
exports.readTranslationFileContent = readTranslationFileContent;
|
|
46
44
|
function mergeTranslationFileContent({ existingContent = {}, newContent, options, }) {
|
|
47
45
|
// Apply messagePrefix to all messages
|
|
48
46
|
const newContentTransformed = lodash_1.default.mapValues(newContent, (value) => ({
|
|
@@ -81,12 +79,10 @@ Maybe you should remove them? ${unknownKeys}`;
|
|
|
81
79
|
await fs_extra_1.default.outputFile(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
|
-
exports.writeTranslationFileContent = writeTranslationFileContent;
|
|
85
82
|
// should we make this configurable?
|
|
86
83
|
function getTranslationsDirPath(context) {
|
|
87
84
|
return path_1.default.resolve(path_1.default.join(context.siteDir, `i18n`));
|
|
88
85
|
}
|
|
89
|
-
exports.getTranslationsDirPath = getTranslationsDirPath;
|
|
90
86
|
function getTranslationsLocaleDirPath(context) {
|
|
91
87
|
return path_1.default.join(getTranslationsDirPath(context), context.locale);
|
|
92
88
|
}
|
|
@@ -94,7 +90,6 @@ exports.getTranslationsLocaleDirPath = getTranslationsLocaleDirPath;
|
|
|
94
90
|
function getCodeTranslationsFilePath(context) {
|
|
95
91
|
return path_1.default.join(getTranslationsLocaleDirPath(context), 'code.json');
|
|
96
92
|
}
|
|
97
|
-
exports.getCodeTranslationsFilePath = getCodeTranslationsFilePath;
|
|
98
93
|
async function readCodeTranslationFileContent(context) {
|
|
99
94
|
return readTranslationFileContent(getCodeTranslationsFilePath(context));
|
|
100
95
|
}
|
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-4724",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,23 +31,23 @@
|
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.17.
|
|
35
|
-
"@babel/generator": "^7.17.
|
|
34
|
+
"@babel/core": "^7.17.7",
|
|
35
|
+
"@babel/generator": "^7.17.7",
|
|
36
36
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
37
37
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
38
38
|
"@babel/preset-env": "^7.16.11",
|
|
39
39
|
"@babel/preset-react": "^7.16.7",
|
|
40
40
|
"@babel/preset-typescript": "^7.16.7",
|
|
41
|
-
"@babel/runtime": "^7.17.
|
|
42
|
-
"@babel/runtime-corejs3": "^7.17.
|
|
41
|
+
"@babel/runtime": "^7.17.7",
|
|
42
|
+
"@babel/runtime-corejs3": "^7.17.7",
|
|
43
43
|
"@babel/traverse": "^7.17.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4724",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4724",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4724",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4724",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4724",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4724",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.1",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
53
|
"autoprefixer": "^10.4.2",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"core-js": "^3.21.1",
|
|
64
64
|
"css-loader": "^6.7.1",
|
|
65
65
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
66
|
-
"cssnano": "^5.
|
|
66
|
+
"cssnano": "^5.1.4",
|
|
67
67
|
"del": "^6.0.0",
|
|
68
68
|
"detect-port": "^1.3.0",
|
|
69
69
|
"escape-html": "^1.0.3",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"react-router-dom": "^5.2.0",
|
|
92
92
|
"remark-admonitions": "^1.2.1",
|
|
93
93
|
"rtl-detect": "^1.0.4",
|
|
94
|
-
"semver": "^7.3.
|
|
94
|
+
"semver": "^7.3.5",
|
|
95
95
|
"serve-handler": "^6.1.3",
|
|
96
96
|
"shelljs": "^0.8.5",
|
|
97
97
|
"terser-webpack-plugin": "^5.3.1",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-4724",
|
|
110
|
+
"@docusaurus/types": "0.0.0-4724",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/nprogress": "^0.2.0",
|
|
113
113
|
"@types/react-dom": "^17.0.13",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "4766d101935a9b634ac4670286aa0f51e35b75ae"
|
|
132
132
|
}
|