@docusaurus/utils 3.8.1 → 3.9.0-canary-6406
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/lib/dataFileUtils.d.ts.map +1 -1
- package/lib/dataFileUtils.js +1 -1
- package/lib/dataFileUtils.js.map +1 -1
- package/lib/i18nUtils.d.ts +2 -27
- package/lib/i18nUtils.d.ts.map +1 -1
- package/lib/i18nUtils.js +11 -22
- package/lib/i18nUtils.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/markdownLinks.d.ts +4 -2
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +30 -13
- package/lib/markdownLinks.js.map +1 -1
- package/package.json +6 -6
- package/src/dataFileUtils.ts +3 -1
- package/src/i18nUtils.ts +13 -46
- package/src/index.ts +1 -1
- package/src/markdownLinks.ts +39 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataFileUtils.d.ts","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAElD,KAAK,cAAc,GAAG;IACpB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS9C;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAe3E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"dataFileUtils.d.ts","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAElD,KAAK,cAAc,GAAG;IACpB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS9C;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAe3E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAIvE;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EAAE,EACrB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAI7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
package/lib/dataFileUtils.js
CHANGED
|
@@ -59,7 +59,7 @@ async function readDataFile(params) {
|
|
|
59
59
|
* in priority.
|
|
60
60
|
*/
|
|
61
61
|
function getContentPathList(contentPaths) {
|
|
62
|
-
return [contentPaths.contentPathLocalized, contentPaths.contentPath];
|
|
62
|
+
return [contentPaths.contentPathLocalized, contentPaths.contentPath].filter((p) => p !== undefined);
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* @param folderPaths a list of absolute paths.
|
package/lib/dataFileUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataFileUtils.js","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAyBH,0CAYC;AAWD,oCAeC;AAOD,
|
|
1
|
+
{"version":3,"file":"dataFileUtils.js","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAyBH,0CAYC;AAWD,oCAeC;AAOD,gDAIC;AAQD,4DAOC;AAYD,0DAeC;;AAlHD,gEAA0B;AAC1B,wDAAwB;AACxB,wEAAwC;AACxC,8DAA2B;AAC3B,mCAA4C;AAa5C;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACG;IACf,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAChD,kBAAkB,CAAC,YAAY,CAAC,EAChC,QAAQ,CACT,CAAC;IACF,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,YAAY,CAAC,MAAsB;IACvD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;QACtE,OAAO,iBAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,gBAAM,CAAC,WAAW,CAAA,oBAAoB,cAAI,CAAC,QAAQ,CAC7D,OAAO,CAAC,GAAG,EAAE,EACb,QAAQ,CACT,qCAAqC,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,EAAC,KAAK,EAAE,GAAY,EAAC,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,YAA0B;IAC3D,OAAO,CAAC,YAAY,CAAC,oBAAoB,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,MAAM,CACzE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,wBAAwB,CAC5C,WAAqB,EACrB,gBAAwB;IAExB,OAAO,IAAA,2BAAmB,EAAC,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE,CACrD,kBAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC,CACvD,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,uBAAuB,CAC3C,WAAqB,EACrB,gBAAwB;IAExB,MAAM,eAAe,GAAG,MAAM,wBAAwB,CACpD,WAAW,EACX,gBAAgB,CACjB,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,SAAS,gBAAgB;IAC3B,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACzB,CAAC;IACJ,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/lib/i18nUtils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
import type { TranslationFileContent, TranslationFile, I18n } from '@docusaurus/types';
|
|
7
|
+
import type { TranslationFileContent, TranslationFile, I18n, I18nLocaleConfig } from '@docusaurus/types';
|
|
8
8
|
/**
|
|
9
9
|
* Takes a list of translation file contents, and shallow-merges them into one.
|
|
10
10
|
*/
|
|
@@ -24,30 +24,5 @@ export declare function getPluginI18nPath({ localizationDir, pluginName, pluginI
|
|
|
24
24
|
pluginId?: string | undefined;
|
|
25
25
|
subPaths?: string[];
|
|
26
26
|
}): string;
|
|
27
|
-
|
|
28
|
-
* Takes a path and returns a localized a version (which is basically `path +
|
|
29
|
-
* i18n.currentLocale`).
|
|
30
|
-
*
|
|
31
|
-
* This is used to resolve the `outDir` and `baseUrl` of each locale; it is NOT
|
|
32
|
-
* used to determine plugin localization file locations.
|
|
33
|
-
*/
|
|
34
|
-
export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
|
|
35
|
-
/**
|
|
36
|
-
* FS paths will treat Windows specially; URL paths will always have a
|
|
37
|
-
* trailing slash to make it a valid base URL.
|
|
38
|
-
*/
|
|
39
|
-
pathType: 'fs' | 'url';
|
|
40
|
-
/** The path, URL or file path, to be localized. */
|
|
41
|
-
path: string;
|
|
42
|
-
/** The current i18n context. */
|
|
43
|
-
i18n: I18n;
|
|
44
|
-
options?: {
|
|
45
|
-
/**
|
|
46
|
-
* By default, we don't localize the path of defaultLocale. This option
|
|
47
|
-
* would override that behavior. Setting `false` is useful for `yarn build
|
|
48
|
-
* -l zh-Hans` to always emit into the root build directory.
|
|
49
|
-
*/
|
|
50
|
-
localizePath?: boolean;
|
|
51
|
-
};
|
|
52
|
-
}): string;
|
|
27
|
+
export declare function getLocaleConfig(i18n: I18n, locale?: string): I18nLocaleConfig;
|
|
53
28
|
//# sourceMappingURL=i18nUtils.d.ts.map
|
package/lib/i18nUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,IAAI,
|
|
1
|
+
{"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,IAAI,EACJ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,sBAAsB,EAAE,GACjC,sBAAsB,CAExB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACzC,eAAe,CAQjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,eAAe,EACf,UAAU,EACV,QAA4B,EAC5B,QAAa,GACd,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,MAAM,CAQT;AAKD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAS7E"}
|
package/lib/i18nUtils.js
CHANGED
|
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.mergeTranslations = mergeTranslations;
|
|
10
10
|
exports.updateTranslationFileMessages = updateTranslationFileMessages;
|
|
11
11
|
exports.getPluginI18nPath = getPluginI18nPath;
|
|
12
|
-
exports.
|
|
12
|
+
exports.getLocaleConfig = getLocaleConfig;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
15
15
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
16
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
16
17
|
const constants_1 = require("./constants");
|
|
17
|
-
const urlUtils_1 = require("./urlUtils");
|
|
18
18
|
/**
|
|
19
19
|
* Takes a list of translation file contents, and shallow-merges them into one.
|
|
20
20
|
*/
|
|
@@ -44,26 +44,15 @@ function getPluginI18nPath({ localizationDir, pluginName, pluginId = constants_1
|
|
|
44
44
|
// ie: return "docs", not "docs-default" nor "docs/default"
|
|
45
45
|
`${pluginName}${pluginId === constants_1.DEFAULT_PLUGIN_ID ? '' : `-${pluginId}`}`, ...subPaths);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const shouldLocalizePath = options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
|
|
56
|
-
if (!shouldLocalizePath) {
|
|
57
|
-
return originalPath;
|
|
58
|
-
}
|
|
59
|
-
// FS paths need special care, for Windows support. Note: we don't use the
|
|
60
|
-
// locale config's `path` here, because this function is used for resolving
|
|
61
|
-
// outDir, which must be the same as baseUrl. When we have the baseUrl config,
|
|
62
|
-
// we need to sync the two.
|
|
63
|
-
if (pathType === 'fs') {
|
|
64
|
-
return path_1.default.join(originalPath, i18n.currentLocale);
|
|
47
|
+
// TODO we may extract this to a separate package
|
|
48
|
+
// we want to use it on the frontend too
|
|
49
|
+
// but "docusaurus-utils-common" (agnostic utils) is not an ideal place since
|
|
50
|
+
function getLocaleConfig(i18n, locale) {
|
|
51
|
+
const localeToLookFor = locale ?? i18n.currentLocale;
|
|
52
|
+
const localeConfig = i18n.localeConfigs[localeToLookFor];
|
|
53
|
+
if (!localeConfig) {
|
|
54
|
+
throw new Error(`Can't find locale config for locale ${logger_1.default.code(localeToLookFor)}`);
|
|
65
55
|
}
|
|
66
|
-
|
|
67
|
-
return (0, urlUtils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
|
|
56
|
+
return localeConfig;
|
|
68
57
|
}
|
|
69
58
|
//# sourceMappingURL=i18nUtils.js.map
|
package/lib/i18nUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgBH,8CAIC;AAMD,sEAWC;AAMD,8CAkBC;AAKD,0CASC;;AAzED,wDAAwB;AACxB,4DAAuB;AACvB,wEAAwC;AACxC,2CAA8C;AAQ9C;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,QAAkC;IAElC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,OAAO,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,eAAgC,EAChC,aAA0C;IAE1C,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,gBAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,WAAW;YACd,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAChC,eAAe,EACf,UAAU,EACV,QAAQ,GAAG,6BAAiB,EAC5B,QAAQ,GAAG,EAAE,GAMd;IACC,OAAO,cAAI,CAAC,IAAI,CACd,eAAe;IACf,gDAAgD;IAChD,2DAA2D;IAC3D,GAAG,UAAU,GAAG,QAAQ,KAAK,6BAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,EAAE,EACtE,GAAG,QAAQ,CACZ,CAAC;AACJ,CAAC;AAED,iDAAiD;AACjD,yCAAyC;AACzC,8EAA8E;AAC9E,SAAgB,eAAe,CAAC,IAAU,EAAE,MAAe;IACzD,MAAM,eAAe,GAAG,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,uCAAuC,gBAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DOCUSAURUS_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, DEFAULT_STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, DEFAULT_I18N_DIR_NAME, CODE_TRANSLATIONS_FILE_NAME, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
|
|
8
8
|
export { generate, readOutputHTMLFile } from './emitUtils';
|
|
9
9
|
export { getFileCommitDate, FileNotTrackedError, GitNotFoundError, } from './gitUtils';
|
|
10
|
-
export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath,
|
|
10
|
+
export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, getLocaleConfig, } from './i18nUtils';
|
|
11
11
|
export { mapAsyncSequential, findAsyncSequential } from './jsUtils';
|
|
12
12
|
export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, parseURLPath, parseLocalURLPath, parseURLOrPath, toURLPath, serializeURLPath, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
|
|
13
13
|
export type { URLPath } from './urlUtils';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,WA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CAAC;AACxB,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,QAAQ,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -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.parseMarkdownContentTitle = exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.
|
|
9
|
+
exports.parseMarkdownContentTitle = exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getLocaleConfig = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
|
|
10
10
|
exports.reportInlineTags = exports.normalizeTags = exports.LAST_UPDATE_FALLBACK = exports.readLastUpdateData = exports.getLastUpdate = exports.getGitLastUpdate = exports.flattenRoutes = exports.askPreferredLanguage = exports.escapeRegexp = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.readDataFile = exports.getDataFilePath = exports.loadFreshModule = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.globTranslatableSourceFiles = exports.safeGlobby = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.parseMarkdownFile = void 0;
|
|
11
11
|
var constants_1 = require("./constants");
|
|
12
12
|
Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
|
|
@@ -36,7 +36,7 @@ var i18nUtils_1 = require("./i18nUtils");
|
|
|
36
36
|
Object.defineProperty(exports, "mergeTranslations", { enumerable: true, get: function () { return i18nUtils_1.mergeTranslations; } });
|
|
37
37
|
Object.defineProperty(exports, "updateTranslationFileMessages", { enumerable: true, get: function () { return i18nUtils_1.updateTranslationFileMessages; } });
|
|
38
38
|
Object.defineProperty(exports, "getPluginI18nPath", { enumerable: true, get: function () { return i18nUtils_1.getPluginI18nPath; } });
|
|
39
|
-
Object.defineProperty(exports, "
|
|
39
|
+
Object.defineProperty(exports, "getLocaleConfig", { enumerable: true, get: function () { return i18nUtils_1.getLocaleConfig; } });
|
|
40
40
|
var jsUtils_1 = require("./jsUtils");
|
|
41
41
|
Object.defineProperty(exports, "mapAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.mapAsyncSequential; } });
|
|
42
42
|
Object.defineProperty(exports, "findAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.findAsyncSequential; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAiBqB;AAhBnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB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AAA,OAAO,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,qGAAA,QAAQ,OAAA;AACrC,yCAOqB;AANnB,mGAAA,MAAM,OAAA;AACN,+GAAA,kBAAkB,OAAA;AAClB,uGAAA,UAAU,OAAA;AACV,wHAAA,2BAA2B,OAAA;AAC3B,0GAAA,aAAa,OAAA;AACb,0HAAA,6BAA6B,OAAA;AAE/B,+CAIwB;AAHtB,kHAAA,kBAAkB,OAAA;AAClB,4HAAA,4BAA4B,OAAA;AAG9B,6CAA8C;AAAtC,8GAAA,eAAe,OAAA;AACvB,iDAMyB;AALvB,gHAAA,eAAe,OAAA;AACf,6GAAA,YAAY,OAAA;AACZ,mHAAA,kBAAkB,OAAA;AAClB,yHAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA;AAEzB,mEAA6D;AAArD,iHAAA,OAAO,OAAA;AAAE,oHAAA,UAAU,OAAA;AAC3B,6CAA2C;AAAnC,2GAAA,YAAY,OAAA;AACpB,uCAAgD;AAAxC,gHAAA,oBAAoB,OAAA;AAC5B,2CAA2C;AAAnC,2GAAA,aAAa,OAAA;AAErB,qDAO2B;AANzB,mHAAA,gBAAgB,OAAA;AAChB,gHAAA,aAAa,OAAA;AACb,qHAAA,kBAAkB,OAAA;AAClB,uHAAA,oBAAoB,OAAA;AAKtB,+BAAuD;AAA/C,qGAAA,aAAa,OAAA;AAAE,wGAAA,gBAAgB,OAAA"}
|
package/lib/markdownLinks.d.ts
CHANGED
|
@@ -15,9 +15,11 @@ export type ContentPaths = {
|
|
|
15
15
|
contentPath: string;
|
|
16
16
|
/**
|
|
17
17
|
* The absolute path to the localized content directory, like
|
|
18
|
-
* `"<siteDir>/i18n/zh-Hans/plugin-content-
|
|
18
|
+
* `"<siteDir>/i18n/zh-Hans/plugin-content-blog"`.
|
|
19
|
+
*
|
|
20
|
+
* Undefined when the locale has `translate: false` config
|
|
19
21
|
*/
|
|
20
|
-
contentPathLocalized: string;
|
|
22
|
+
contentPathLocalized: string | undefined;
|
|
21
23
|
};
|
|
22
24
|
/** Data structure representing each broken Markdown link to be reported. */
|
|
23
25
|
export type BrokenMarkdownLink<T extends ContentPaths> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,GAAG,CACjC,MAAM,EAAE,gDAAgD;AACxD,MAAM,CACP,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,GACA,MAAM,GAAG,IAAI,CA6Cf"}
|
package/lib/markdownLinks.js
CHANGED
|
@@ -11,24 +11,41 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const dataFileUtils_1 = require("./dataFileUtils");
|
|
13
13
|
const pathUtils_1 = require("./pathUtils");
|
|
14
|
-
// Note this is historical logic extracted during a 2024 refactor
|
|
15
|
-
// The algo has been kept exactly as before for retro compatibility
|
|
16
|
-
// See also https://github.com/facebook/docusaurus/pull/10168
|
|
17
14
|
function resolveMarkdownLinkPathname(linkPathname, context) {
|
|
18
15
|
const { sourceFilePath, sourceToPermalink, contentPaths, siteDir } = context;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
sourceDirsToTry.push(...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir);
|
|
16
|
+
// If the link is already @site aliased, there's no need to resolve it
|
|
17
|
+
if (linkPathname.startsWith('@site/')) {
|
|
18
|
+
return sourceToPermalink.get(decodeURIComponent(linkPathname)) ?? null;
|
|
23
19
|
}
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
// Get the dirs to "look into", ordered by priority, when resolving the link
|
|
21
|
+
function getSourceDirsToTry() {
|
|
22
|
+
// /file.md is always resolved from
|
|
23
|
+
// - the plugin content paths,
|
|
24
|
+
// - then siteDir
|
|
25
|
+
if (linkPathname.startsWith('/')) {
|
|
26
|
+
return [...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir];
|
|
27
|
+
}
|
|
28
|
+
// ./file.md and ../file.md are always resolved from
|
|
29
|
+
// - the current file dir
|
|
30
|
+
else if (linkPathname.startsWith('./') || linkPathname.startsWith('../')) {
|
|
31
|
+
return [path_1.default.dirname(sourceFilePath)];
|
|
32
|
+
}
|
|
33
|
+
// file.md is resolved from
|
|
34
|
+
// - the current file dir,
|
|
35
|
+
// - then from the plugin content paths,
|
|
36
|
+
// - then siteDir
|
|
37
|
+
else {
|
|
38
|
+
return [
|
|
39
|
+
path_1.default.dirname(sourceFilePath),
|
|
40
|
+
...(0, dataFileUtils_1.getContentPathList)(contentPaths),
|
|
41
|
+
siteDir,
|
|
42
|
+
];
|
|
43
|
+
}
|
|
27
44
|
}
|
|
28
|
-
const
|
|
45
|
+
const sourcesToTry = getSourceDirsToTry()
|
|
29
46
|
.map((sourceDir) => path_1.default.join(sourceDir, decodeURIComponent(linkPathname)))
|
|
30
|
-
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir))
|
|
31
|
-
|
|
47
|
+
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir));
|
|
48
|
+
const aliasedSourceMatch = sourcesToTry.find((source) => sourceToPermalink.has(source));
|
|
32
49
|
return aliasedSourceMatch
|
|
33
50
|
? sourceToPermalink.get(aliasedSourceMatch) ?? null
|
|
34
51
|
: null;
|
package/lib/markdownLinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA4CH,kEAqDC;;AA/FD,wDAAwB;AACxB,mDAAmD;AACnD,2CAA4C;AAwC5C,SAAgB,2BAA2B,CACzC,YAAoB,EACpB,OAKC;IAED,MAAM,EAAC,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAC,GAAG,OAAO,CAAC;IAE3E,sEAAsE;IACtE,IAAI,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,OAAO,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC;IACzE,CAAC;IAED,4EAA4E;IAC5E,SAAS,kBAAkB;QACzB,mCAAmC;QACnC,8BAA8B;QAC9B,iBAAiB;QACjB,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,IAAA,kCAAkB,EAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,oDAAoD;QACpD,yBAAyB;aACpB,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACzE,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,2BAA2B;QAC3B,0BAA0B;QAC1B,wCAAwC;QACxC,iBAAiB;aACZ,CAAC;YACJ,OAAO;gBACL,cAAI,CAAC,OAAO,CAAC,cAAc,CAAC;gBAC5B,GAAG,IAAA,kCAAkB,EAAC,YAAY,CAAC;gBACnC,OAAO;aACR,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,kBAAkB,EAAE;SACtC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;SAC1E,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,2BAAe,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAErD,MAAM,kBAAkB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACtD,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAC9B,CAAC;IAEF,OAAO,kBAAkB;QACvB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI;QACnD,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0-canary-6406",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.
|
|
22
|
-
"@docusaurus/types": "3.
|
|
23
|
-
"@docusaurus/utils-common": "3.
|
|
21
|
+
"@docusaurus/logger": "3.9.0-canary-6406",
|
|
22
|
+
"@docusaurus/types": "3.9.0-canary-6406",
|
|
23
|
+
"@docusaurus/utils-common": "3.9.0-canary-6406",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"execa": "5.1.1",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"webpack": "^5.88.1"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
44
|
+
"node": ">=20.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/dedent": "^0.7.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"dedent": "^0.7.0",
|
|
52
52
|
"tmp-promise": "^3.0.3"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "796441f4f831278ffc57971fabcd4c730da9e9d7"
|
|
55
55
|
}
|
package/src/dataFileUtils.ts
CHANGED
|
@@ -74,7 +74,9 @@ export async function readDataFile(params: DataFileParams): Promise<unknown> {
|
|
|
74
74
|
* in priority.
|
|
75
75
|
*/
|
|
76
76
|
export function getContentPathList(contentPaths: ContentPaths): string[] {
|
|
77
|
-
return [contentPaths.contentPathLocalized, contentPaths.contentPath]
|
|
77
|
+
return [contentPaths.contentPathLocalized, contentPaths.contentPath].filter(
|
|
78
|
+
(p) => p !== undefined,
|
|
79
|
+
);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
/**
|
package/src/i18nUtils.ts
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import _ from 'lodash';
|
|
10
|
+
import logger from '@docusaurus/logger';
|
|
10
11
|
import {DEFAULT_PLUGIN_ID} from './constants';
|
|
11
|
-
import {normalizeUrl} from './urlUtils';
|
|
12
12
|
import type {
|
|
13
13
|
TranslationFileContent,
|
|
14
14
|
TranslationFile,
|
|
15
15
|
I18n,
|
|
16
|
+
I18nLocaleConfig,
|
|
16
17
|
} from '@docusaurus/types';
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -65,50 +66,16 @@ export function getPluginI18nPath({
|
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
i18n,
|
|
79
|
-
options = {},
|
|
80
|
-
}: {
|
|
81
|
-
/**
|
|
82
|
-
* FS paths will treat Windows specially; URL paths will always have a
|
|
83
|
-
* trailing slash to make it a valid base URL.
|
|
84
|
-
*/
|
|
85
|
-
pathType: 'fs' | 'url';
|
|
86
|
-
/** The path, URL or file path, to be localized. */
|
|
87
|
-
path: string;
|
|
88
|
-
/** The current i18n context. */
|
|
89
|
-
i18n: I18n;
|
|
90
|
-
options?: {
|
|
91
|
-
/**
|
|
92
|
-
* By default, we don't localize the path of defaultLocale. This option
|
|
93
|
-
* would override that behavior. Setting `false` is useful for `yarn build
|
|
94
|
-
* -l zh-Hans` to always emit into the root build directory.
|
|
95
|
-
*/
|
|
96
|
-
localizePath?: boolean;
|
|
97
|
-
};
|
|
98
|
-
}): string {
|
|
99
|
-
const shouldLocalizePath: boolean =
|
|
100
|
-
options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
|
|
101
|
-
|
|
102
|
-
if (!shouldLocalizePath) {
|
|
103
|
-
return originalPath;
|
|
104
|
-
}
|
|
105
|
-
// FS paths need special care, for Windows support. Note: we don't use the
|
|
106
|
-
// locale config's `path` here, because this function is used for resolving
|
|
107
|
-
// outDir, which must be the same as baseUrl. When we have the baseUrl config,
|
|
108
|
-
// we need to sync the two.
|
|
109
|
-
if (pathType === 'fs') {
|
|
110
|
-
return path.join(originalPath, i18n.currentLocale);
|
|
69
|
+
// TODO we may extract this to a separate package
|
|
70
|
+
// we want to use it on the frontend too
|
|
71
|
+
// but "docusaurus-utils-common" (agnostic utils) is not an ideal place since
|
|
72
|
+
export function getLocaleConfig(i18n: I18n, locale?: string): I18nLocaleConfig {
|
|
73
|
+
const localeToLookFor = locale ?? i18n.currentLocale;
|
|
74
|
+
const localeConfig = i18n.localeConfigs[localeToLookFor];
|
|
75
|
+
if (!localeConfig) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Can't find locale config for locale ${logger.code(localeToLookFor)}`,
|
|
78
|
+
);
|
|
111
79
|
}
|
|
112
|
-
|
|
113
|
-
return normalizeUrl([originalPath, i18n.currentLocale, '/']);
|
|
80
|
+
return localeConfig;
|
|
114
81
|
}
|
package/src/index.ts
CHANGED
package/src/markdownLinks.ts
CHANGED
|
@@ -20,9 +20,11 @@ export type ContentPaths = {
|
|
|
20
20
|
contentPath: string;
|
|
21
21
|
/**
|
|
22
22
|
* The absolute path to the localized content directory, like
|
|
23
|
-
* `"<siteDir>/i18n/zh-Hans/plugin-content-
|
|
23
|
+
* `"<siteDir>/i18n/zh-Hans/plugin-content-blog"`.
|
|
24
|
+
*
|
|
25
|
+
* Undefined when the locale has `translate: false` config
|
|
24
26
|
*/
|
|
25
|
-
contentPathLocalized: string;
|
|
27
|
+
contentPathLocalized: string | undefined;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
/** Data structure representing each broken Markdown link to be reported. */
|
|
@@ -45,9 +47,6 @@ export type SourceToPermalink = Map<
|
|
|
45
47
|
string // Permalink: "/docs/content"
|
|
46
48
|
>;
|
|
47
49
|
|
|
48
|
-
// Note this is historical logic extracted during a 2024 refactor
|
|
49
|
-
// The algo has been kept exactly as before for retro compatibility
|
|
50
|
-
// See also https://github.com/facebook/docusaurus/pull/10168
|
|
51
50
|
export function resolveMarkdownLinkPathname(
|
|
52
51
|
linkPathname: string,
|
|
53
52
|
context: {
|
|
@@ -58,20 +57,45 @@ export function resolveMarkdownLinkPathname(
|
|
|
58
57
|
},
|
|
59
58
|
): string | null {
|
|
60
59
|
const {sourceFilePath, sourceToPermalink, contentPaths, siteDir} = context;
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
if (
|
|
64
|
-
|
|
60
|
+
|
|
61
|
+
// If the link is already @site aliased, there's no need to resolve it
|
|
62
|
+
if (linkPathname.startsWith('@site/')) {
|
|
63
|
+
return sourceToPermalink.get(decodeURIComponent(linkPathname)) ?? null;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
|
|
66
|
+
// Get the dirs to "look into", ordered by priority, when resolving the link
|
|
67
|
+
function getSourceDirsToTry() {
|
|
68
|
+
// /file.md is always resolved from
|
|
69
|
+
// - the plugin content paths,
|
|
70
|
+
// - then siteDir
|
|
71
|
+
if (linkPathname.startsWith('/')) {
|
|
72
|
+
return [...getContentPathList(contentPaths), siteDir];
|
|
73
|
+
}
|
|
74
|
+
// ./file.md and ../file.md are always resolved from
|
|
75
|
+
// - the current file dir
|
|
76
|
+
else if (linkPathname.startsWith('./') || linkPathname.startsWith('../')) {
|
|
77
|
+
return [path.dirname(sourceFilePath)];
|
|
78
|
+
}
|
|
79
|
+
// file.md is resolved from
|
|
80
|
+
// - the current file dir,
|
|
81
|
+
// - then from the plugin content paths,
|
|
82
|
+
// - then siteDir
|
|
83
|
+
else {
|
|
84
|
+
return [
|
|
85
|
+
path.dirname(sourceFilePath),
|
|
86
|
+
...getContentPathList(contentPaths),
|
|
87
|
+
siteDir,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
91
|
|
|
71
|
-
const
|
|
92
|
+
const sourcesToTry = getSourceDirsToTry()
|
|
72
93
|
.map((sourceDir) => path.join(sourceDir, decodeURIComponent(linkPathname)))
|
|
73
|
-
.map((source) => aliasedSitePath(source, siteDir))
|
|
74
|
-
|
|
94
|
+
.map((source) => aliasedSitePath(source, siteDir));
|
|
95
|
+
|
|
96
|
+
const aliasedSourceMatch = sourcesToTry.find((source) =>
|
|
97
|
+
sourceToPermalink.has(source),
|
|
98
|
+
);
|
|
75
99
|
|
|
76
100
|
return aliasedSourceMatch
|
|
77
101
|
? sourceToPermalink.get(aliasedSourceMatch) ?? null
|