@docusaurus/core 2.0.0-beta.2 → 2.0.0-beta.22
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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/docusaurus.mjs +221 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -8
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +40 -40
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +6 -13
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +108 -146
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +104 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +29 -28
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +109 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +101 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +118 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +46 -25
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +4 -4
- package/lib/server/configValidation.js +86 -41
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -13
- package/lib/server/index.js +83 -165
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +9 -8
- package/lib/server/plugins/index.js +73 -134
- package/lib/server/plugins/init.d.ts +6 -5
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +5 -1
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +14 -19
- package/lib/server/translations/translations.js +40 -72
- package/lib/server/translations/translationsExtractor.d.ts +10 -4
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +45 -57
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +33 -17
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +22 -9
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +3 -2
- package/lib/webpack/utils.d.ts +15 -31
- package/lib/webpack/utils.js +61 -182
- package/package.json +81 -77
- package/bin/docusaurus.js +0 -325
- package/lib/.tsbuildinfo +0 -1
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -1
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -40
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/plugins/applyRouteTrailingSlash.d.ts +0 -8
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -40
- package/lib/server/themes/index.d.ts +0 -12
- package/lib/server/themes/index.js +0 -47
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.themeComponentsTable = exports.helpTables = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
|
+
const cli_table3_1 = tslib_1.__importDefault(require("cli-table3"));
|
|
14
|
+
const actions_1 = require("./actions");
|
|
15
|
+
const common_1 = require("./common");
|
|
16
|
+
function tableStatusLabel(status) {
|
|
17
|
+
return (0, common_1.actionStatusColor)(status, (0, common_1.actionStatusLabel)(status));
|
|
18
|
+
}
|
|
19
|
+
function getStatusLabel(status) {
|
|
20
|
+
return (0, common_1.actionStatusColor)(status, (0, common_1.actionStatusLabel)(status));
|
|
21
|
+
}
|
|
22
|
+
function statusTable() {
|
|
23
|
+
const table = new cli_table3_1.default({
|
|
24
|
+
head: ['Status', 'CLI option', 'Description'],
|
|
25
|
+
});
|
|
26
|
+
table.push({
|
|
27
|
+
[tableStatusLabel('safe')]: [
|
|
28
|
+
'',
|
|
29
|
+
`
|
|
30
|
+
This component is safe to swizzle and was designed for this purpose.
|
|
31
|
+
The swizzled component is retro-compatible with minor version upgrades.
|
|
32
|
+
`,
|
|
33
|
+
],
|
|
34
|
+
}, {
|
|
35
|
+
[tableStatusLabel('unsafe')]: [
|
|
36
|
+
logger_1.default.code('--danger'),
|
|
37
|
+
`
|
|
38
|
+
This component is unsafe to swizzle, but you can still do it!
|
|
39
|
+
Warning: we may release breaking changes within minor version upgrades.
|
|
40
|
+
You will have to upgrade your component manually and maintain it over time.
|
|
41
|
+
|
|
42
|
+
${logger_1.default.green('Tip')}: your customization can't be done in a ${tableStatusLabel('safe')} way?
|
|
43
|
+
Report it here: https://github.com/facebook/docusaurus/discussions/5468
|
|
44
|
+
`,
|
|
45
|
+
],
|
|
46
|
+
}, {
|
|
47
|
+
[tableStatusLabel('forbidden')]: [
|
|
48
|
+
'',
|
|
49
|
+
`
|
|
50
|
+
This component is not meant to be swizzled.
|
|
51
|
+
`,
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
return table.toString();
|
|
55
|
+
}
|
|
56
|
+
function actionsTable() {
|
|
57
|
+
const table = new cli_table3_1.default({
|
|
58
|
+
head: ['Actions', 'CLI option', 'Description'],
|
|
59
|
+
});
|
|
60
|
+
table.push({
|
|
61
|
+
[logger_1.default.bold('Wrap')]: [
|
|
62
|
+
logger_1.default.code('--wrap'),
|
|
63
|
+
`
|
|
64
|
+
Creates a wrapper around the original theme component.
|
|
65
|
+
Allows rendering other components before/after the original theme component.
|
|
66
|
+
|
|
67
|
+
${logger_1.default.green('Tip')}: prefer ${logger_1.default.code('--wrap')} whenever possible to reduce the amount of code to maintain.
|
|
68
|
+
`,
|
|
69
|
+
],
|
|
70
|
+
}, {
|
|
71
|
+
[logger_1.default.bold('Eject')]: [
|
|
72
|
+
logger_1.default.code('--eject'),
|
|
73
|
+
`
|
|
74
|
+
Ejects the full source code of the original theme component.
|
|
75
|
+
Allows overriding of the original component entirely with your own UI and logic.
|
|
76
|
+
|
|
77
|
+
${logger_1.default.green('Tip')}: ${logger_1.default.code('--eject')} can be useful for completely redesigning a component.
|
|
78
|
+
`,
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
return table.toString();
|
|
82
|
+
}
|
|
83
|
+
function helpTables() {
|
|
84
|
+
return `${logger_1.default.bold('Swizzle actions')}:
|
|
85
|
+
${actionsTable()}
|
|
86
|
+
|
|
87
|
+
${logger_1.default.bold('Swizzle safety statuses')}:
|
|
88
|
+
${statusTable()}
|
|
89
|
+
|
|
90
|
+
${logger_1.default.bold('Swizzle guide')}: https://docusaurus.io/docs/swizzling`;
|
|
91
|
+
}
|
|
92
|
+
exports.helpTables = helpTables;
|
|
93
|
+
function themeComponentsTable(themeComponents) {
|
|
94
|
+
const table = new cli_table3_1.default({
|
|
95
|
+
head: [
|
|
96
|
+
'Component name',
|
|
97
|
+
...actions_1.SwizzleActions.map((action) => lodash_1.default.capitalize(action)),
|
|
98
|
+
'Description',
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
themeComponents.all.forEach((component) => {
|
|
102
|
+
table.push({
|
|
103
|
+
[component]: [
|
|
104
|
+
...actions_1.SwizzleActions.map((action) => getStatusLabel(themeComponents.getActionStatus(component, action))),
|
|
105
|
+
themeComponents.getDescription(component),
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
return `${logger_1.default.bold(`Components available for swizzle in ${logger_1.default.name(themeComponents.themeName)}`)}:
|
|
110
|
+
${table.toString()}
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
exports.themeComponentsTable = themeComponentsTable;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { type SwizzlePlugin } from './common';
|
|
8
|
+
export declare function pluginToThemeName(plugin: SwizzlePlugin): string | undefined;
|
|
9
|
+
export declare function getPluginByThemeName(plugins: SwizzlePlugin[], themeName: string): SwizzlePlugin;
|
|
10
|
+
export declare function getThemeNames(plugins: SwizzlePlugin[]): string[];
|
|
11
|
+
export declare function getThemeName({ themeNameParam, themeNames, list, }: {
|
|
12
|
+
themeNameParam: string | undefined;
|
|
13
|
+
themeNames: string[];
|
|
14
|
+
list: boolean | undefined;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
export declare function getThemePath({ plugins, themeName, typescript, }: {
|
|
17
|
+
plugins: SwizzlePlugin[];
|
|
18
|
+
themeName: string;
|
|
19
|
+
typescript: boolean | undefined;
|
|
20
|
+
}): string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getThemePath = exports.getThemeName = exports.getThemeNames = exports.getPluginByThemeName = exports.pluginToThemeName = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
|
+
const leven_1 = tslib_1.__importDefault(require("leven"));
|
|
15
|
+
const prompts_1 = require("./prompts");
|
|
16
|
+
const common_1 = require("./common");
|
|
17
|
+
function pluginToThemeName(plugin) {
|
|
18
|
+
if (plugin.instance.getThemePath) {
|
|
19
|
+
return (plugin.instance.version.name ?? plugin.instance.name);
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
exports.pluginToThemeName = pluginToThemeName;
|
|
24
|
+
function getPluginByThemeName(plugins, themeName) {
|
|
25
|
+
const plugin = plugins.find((p) => pluginToThemeName(p) === themeName);
|
|
26
|
+
if (!plugin) {
|
|
27
|
+
throw new Error(`Theme ${themeName} not found`);
|
|
28
|
+
}
|
|
29
|
+
return plugin;
|
|
30
|
+
}
|
|
31
|
+
exports.getPluginByThemeName = getPluginByThemeName;
|
|
32
|
+
function getThemeNames(plugins) {
|
|
33
|
+
const themeNames = lodash_1.default.uniq(
|
|
34
|
+
// The fact that getThemePath is attached to the plugin instance makes
|
|
35
|
+
// this code impossible to optimize. If this is a static method, we don't
|
|
36
|
+
// need to initialize all plugins just to filter which are themes
|
|
37
|
+
// Benchmark: loadContext-58ms; initPlugins-323ms
|
|
38
|
+
plugins.map((plugin) => pluginToThemeName(plugin)).filter(Boolean));
|
|
39
|
+
// Opinionated ordering: user is most likely to swizzle:
|
|
40
|
+
// - the classic theme
|
|
41
|
+
// - official themes
|
|
42
|
+
// - official plugins
|
|
43
|
+
return lodash_1.default.orderBy(themeNames, [
|
|
44
|
+
(t) => t === '@docusaurus/theme-classic',
|
|
45
|
+
(t) => t.includes('@docusaurus/theme'),
|
|
46
|
+
(t) => t.includes('@docusaurus'),
|
|
47
|
+
], ['desc', 'desc', 'desc']);
|
|
48
|
+
}
|
|
49
|
+
exports.getThemeNames = getThemeNames;
|
|
50
|
+
// Returns a valid value if recovering is possible
|
|
51
|
+
function handleInvalidThemeName({ themeNameParam, themeNames, }) {
|
|
52
|
+
// Trying to recover invalid value
|
|
53
|
+
// We look for potential matches that only differ in casing.
|
|
54
|
+
const differentCaseMatch = (0, common_1.findStringIgnoringCase)(themeNameParam, themeNames);
|
|
55
|
+
if (differentCaseMatch) {
|
|
56
|
+
logger_1.default.warn `Theme name=${themeNameParam} doesn't exist.`;
|
|
57
|
+
logger_1.default.info `name=${differentCaseMatch} will be used instead of name=${themeNameParam}.`;
|
|
58
|
+
return differentCaseMatch;
|
|
59
|
+
}
|
|
60
|
+
// TODO recover from short theme-names here: "classic" => "@docusaurus/theme-classic"
|
|
61
|
+
// No recovery value is possible: print error
|
|
62
|
+
const suggestion = themeNames.find((name) => (0, leven_1.default)(name, themeNameParam) < 4);
|
|
63
|
+
logger_1.default.error `Theme name=${themeNameParam} not found. ${suggestion
|
|
64
|
+
? logger_1.default.interpolate `Did you mean name=${suggestion}?`
|
|
65
|
+
: logger_1.default.interpolate `Themes available for swizzle: ${themeNames}`}`;
|
|
66
|
+
return process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
function validateThemeName({ themeNameParam, themeNames, }) {
|
|
69
|
+
const isValidName = themeNames.includes(themeNameParam);
|
|
70
|
+
if (!isValidName) {
|
|
71
|
+
return handleInvalidThemeName({
|
|
72
|
+
themeNameParam,
|
|
73
|
+
themeNames,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return themeNameParam;
|
|
77
|
+
}
|
|
78
|
+
async function getThemeName({ themeNameParam, themeNames, list, }) {
|
|
79
|
+
if (list && !themeNameParam) {
|
|
80
|
+
logger_1.default.info `Themes available for swizzle: name=${themeNames}`;
|
|
81
|
+
return process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
return themeNameParam
|
|
84
|
+
? validateThemeName({ themeNameParam, themeNames })
|
|
85
|
+
: (0, prompts_1.askThemeName)(themeNames);
|
|
86
|
+
}
|
|
87
|
+
exports.getThemeName = getThemeName;
|
|
88
|
+
function getThemePath({ plugins, themeName, typescript, }) {
|
|
89
|
+
const pluginInstance = getPluginByThemeName(plugins, themeName);
|
|
90
|
+
const themePath = typescript
|
|
91
|
+
? pluginInstance.instance.getTypeScriptThemePath &&
|
|
92
|
+
path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getTypeScriptThemePath())
|
|
93
|
+
: pluginInstance.instance.getThemePath &&
|
|
94
|
+
path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getThemePath());
|
|
95
|
+
if (!themePath) {
|
|
96
|
+
logger_1.default.warn(typescript
|
|
97
|
+
? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
|
|
98
|
+
: // This is... technically possible to happen, e.g. returning undefined
|
|
99
|
+
// from getThemePath. Plugins may intentionally or unintentionally
|
|
100
|
+
// disguise as themes?
|
|
101
|
+
logger_1.default.interpolate `name=${themeName} does not provide any theme code.`);
|
|
102
|
+
return process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
return themePath;
|
|
105
|
+
}
|
|
106
|
+
exports.getThemePath = getThemePath;
|
|
@@ -4,9 +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
|
-
import
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function transformMarkdownHeadingLine(line: string, slugger: GithubSlugger): string;
|
|
10
|
-
export declare function transformMarkdownLine(line: string, slugger: GithubSlugger): string;
|
|
11
|
-
export declare function transformMarkdownContent(content: string): string;
|
|
12
|
-
export default function writeHeadingIds(siteDir: string): Promise<void>;
|
|
7
|
+
import { type WriteHeadingIDOptions } from '@docusaurus/utils';
|
|
8
|
+
export declare function writeHeadingIds(siteDirParam?: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
|
|
@@ -6,105 +6,46 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.writeHeadingIds = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
13
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
14
|
-
const server_1 = require("../server");
|
|
15
|
-
const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
17
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
|
+
const server_1 = require("../server");
|
|
15
|
+
const init_1 = require("../server/plugins/init");
|
|
18
16
|
const utils_2 = require("../server/utils");
|
|
19
|
-
function
|
|
20
|
-
return line.replace(/\[([^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
|
|
21
|
-
}
|
|
22
|
-
exports.unwrapMarkdownLinks = unwrapMarkdownLinks;
|
|
23
|
-
function addHeadingId(line, slugger) {
|
|
24
|
-
let headingLevel = 0;
|
|
25
|
-
while (line.charAt(headingLevel) === '#') {
|
|
26
|
-
headingLevel += 1;
|
|
27
|
-
}
|
|
28
|
-
const headingText = line.slice(headingLevel).trimEnd();
|
|
29
|
-
const headingHashes = line.slice(0, headingLevel);
|
|
30
|
-
const slug = slugger.slug(unwrapMarkdownLinks(headingText));
|
|
31
|
-
return `${headingHashes}${headingText} {#${slug}}`;
|
|
32
|
-
}
|
|
33
|
-
function transformMarkdownHeadingLine(line, slugger) {
|
|
34
|
-
if (!line.startsWith('#')) {
|
|
35
|
-
throw new Error(`Line is not a Markdown heading: ${line}.`);
|
|
36
|
-
}
|
|
37
|
-
const parsedHeading = utils_1.parseMarkdownHeadingId(line);
|
|
38
|
-
// Do not process if id is already therer
|
|
39
|
-
if (parsedHeading.id) {
|
|
40
|
-
return line;
|
|
41
|
-
}
|
|
42
|
-
return addHeadingId(line, slugger);
|
|
43
|
-
}
|
|
44
|
-
exports.transformMarkdownHeadingLine = transformMarkdownHeadingLine;
|
|
45
|
-
function transformMarkdownLine(line, slugger) {
|
|
46
|
-
// Ignore h1 headings on purpose, as we don't create anchor links for those
|
|
47
|
-
if (line.startsWith('##')) {
|
|
48
|
-
return transformMarkdownHeadingLine(line, slugger);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return line;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.transformMarkdownLine = transformMarkdownLine;
|
|
55
|
-
function transformMarkdownLines(lines) {
|
|
56
|
-
let inCode = false;
|
|
57
|
-
const slugger = new github_slugger_1.default();
|
|
58
|
-
return lines.map((line) => {
|
|
59
|
-
if (line.startsWith('```')) {
|
|
60
|
-
inCode = !inCode;
|
|
61
|
-
return line;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (inCode) {
|
|
65
|
-
return line;
|
|
66
|
-
}
|
|
67
|
-
return transformMarkdownLine(line, slugger);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function transformMarkdownContent(content) {
|
|
72
|
-
return transformMarkdownLines(content.split('\n')).join('\n');
|
|
73
|
-
}
|
|
74
|
-
exports.transformMarkdownContent = transformMarkdownContent;
|
|
75
|
-
async function transformMarkdownFile(filepath) {
|
|
17
|
+
async function transformMarkdownFile(filepath, options) {
|
|
76
18
|
const content = await fs_extra_1.default.readFile(filepath, 'utf8');
|
|
77
|
-
const updatedContent =
|
|
19
|
+
const updatedContent = (0, utils_1.writeMarkdownHeadingId)(content, options);
|
|
78
20
|
if (content !== updatedContent) {
|
|
79
21
|
await fs_extra_1.default.writeFile(filepath, updatedContent);
|
|
80
22
|
return filepath;
|
|
81
23
|
}
|
|
82
24
|
return undefined;
|
|
83
25
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
26
|
+
/**
|
|
27
|
+
* We only handle the "paths to watch" because these are the paths where the
|
|
28
|
+
* markdown files are. Also we don't want to transform the site md docs that do
|
|
29
|
+
* not belong to a content plugin. For example ./README.md should not be
|
|
30
|
+
* transformed
|
|
31
|
+
*/
|
|
87
32
|
async function getPathsToWatch(siteDir) {
|
|
88
|
-
const context = await server_1.loadContext(siteDir);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
pluginConfigs,
|
|
92
|
-
context,
|
|
93
|
-
});
|
|
94
|
-
return lodash_1.flatten(plugins.map((plugin) => { var _a, _b; return (_b = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.getPathsToWatch) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; }));
|
|
33
|
+
const context = await (0, server_1.loadContext)({ siteDir });
|
|
34
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
35
|
+
return plugins.flatMap((plugin) => plugin.getPathsToWatch?.() ?? []);
|
|
95
36
|
}
|
|
96
|
-
async function writeHeadingIds(
|
|
97
|
-
const
|
|
37
|
+
async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
|
|
38
|
+
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
39
|
+
const markdownFiles = await (0, utils_2.safeGlobby)(files ?? (await getPathsToWatch(siteDir)), {
|
|
98
40
|
expandDirectories: ['**/*.{md,mdx}'],
|
|
99
41
|
});
|
|
100
|
-
const result = await Promise.all(markdownFiles.map(transformMarkdownFile));
|
|
42
|
+
const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
|
|
101
43
|
const pathsModified = result.filter(Boolean);
|
|
102
44
|
if (pathsModified.length) {
|
|
103
|
-
|
|
104
|
-
- ${pathsModified.join('\n- ')}`));
|
|
45
|
+
logger_1.default.success `Heading ids added to Markdown files (number=${`${pathsModified.length}/${markdownFiles.length}`} files): ${pathsModified}`;
|
|
105
46
|
}
|
|
106
47
|
else {
|
|
107
|
-
|
|
48
|
+
logger_1.default.warn `number=${markdownFiles.length} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.`;
|
|
108
49
|
}
|
|
109
50
|
}
|
|
110
|
-
exports.
|
|
51
|
+
exports.writeHeadingIds = writeHeadingIds;
|
|
@@ -4,8 +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 {
|
|
8
|
-
import { WriteTranslationsOptions } from '../server/translations/translations';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
}): Promise<void>;
|
|
7
|
+
import { type LoadContextOptions } from '../server';
|
|
8
|
+
import { type WriteTranslationsOptions } from '../server/translations/translations';
|
|
9
|
+
export declare type WriteTranslationsCLIOptions = Pick<LoadContextOptions, 'config' | 'locale'> & WriteTranslationsOptions;
|
|
10
|
+
export declare function writeTranslations(siteDirParam?: string, options?: Partial<WriteTranslationsCLIOptions>): Promise<void>;
|
|
@@ -1,58 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.writeTranslations = void 0;
|
|
3
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
13
|
const server_1 = require("../server");
|
|
5
|
-
const init_1 =
|
|
14
|
+
const init_1 = require("../server/plugins/init");
|
|
6
15
|
const translations_1 = require("../server/translations/translations");
|
|
7
16
|
const translationsExtractor_1 = require("../server/translations/translationsExtractor");
|
|
8
17
|
const utils_1 = require("../webpack/utils");
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
/**
|
|
19
|
+
* This is a hack, so that @docusaurus/theme-common translations are extracted!
|
|
20
|
+
* A theme doesn't have a way to express that one of its dependency (like
|
|
21
|
+
* @docusaurus/theme-common) also has translations to extract.
|
|
22
|
+
* Instead of introducing a new lifecycle (like `getThemeTranslationPaths()`?)
|
|
23
|
+
* We just make an exception and assume that user is using an official theme
|
|
24
|
+
*/
|
|
25
|
+
async function getExtraSourceCodeFilePaths() {
|
|
26
|
+
try {
|
|
27
|
+
const themeCommonSourceDir = path_1.default.dirname(require.resolve('@docusaurus/theme-common/lib'));
|
|
28
|
+
return (0, translationsExtractor_1.globSourceCodeFilePaths)([themeCommonSourceDir]);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return []; // User may not use a Docusaurus official theme? Quite unlikely...
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function writePluginTranslationFiles({ localizationDir, plugin, options, }) {
|
|
11
35
|
if (plugin.getTranslationFiles) {
|
|
12
|
-
const content = await
|
|
36
|
+
const content = await plugin.loadContent?.();
|
|
13
37
|
const translationFiles = await plugin.getTranslationFiles({
|
|
14
38
|
content,
|
|
15
39
|
});
|
|
16
40
|
await Promise.all(translationFiles.map(async (translationFile) => {
|
|
17
|
-
await translations_1.writePluginTranslations({
|
|
18
|
-
|
|
41
|
+
await (0, translations_1.writePluginTranslations)({
|
|
42
|
+
localizationDir,
|
|
19
43
|
plugin,
|
|
20
44
|
translationFile,
|
|
21
|
-
locale,
|
|
22
45
|
options,
|
|
23
46
|
});
|
|
24
47
|
}));
|
|
25
48
|
}
|
|
26
49
|
}
|
|
27
|
-
async function writeTranslations(
|
|
28
|
-
|
|
29
|
-
const context = await server_1.loadContext(
|
|
30
|
-
|
|
50
|
+
async function writeTranslations(siteDirParam = '.', options = {}) {
|
|
51
|
+
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
52
|
+
const context = await (0, server_1.loadContext)({
|
|
53
|
+
siteDir,
|
|
54
|
+
config: options.config,
|
|
31
55
|
locale: options.locale,
|
|
32
56
|
});
|
|
33
|
-
const
|
|
34
|
-
const plugins = init_1.
|
|
35
|
-
|
|
36
|
-
context,
|
|
37
|
-
});
|
|
38
|
-
const locale = (_a = options.locale) !== null && _a !== void 0 ? _a : context.i18n.defaultLocale;
|
|
57
|
+
const { localizationDir } = context;
|
|
58
|
+
const plugins = await (0, init_1.initPlugins)(context);
|
|
59
|
+
const locale = options.locale ?? context.i18n.defaultLocale;
|
|
39
60
|
if (!context.i18n.locales.includes(locale)) {
|
|
40
61
|
throw new Error(`Can't write-translation for locale "${locale}" that is not in the locale configuration file.
|
|
41
62
|
Available locales are: ${context.i18n.locales.join(',')}.`);
|
|
42
63
|
}
|
|
43
|
-
const babelOptions = utils_1.getBabelOptions({
|
|
64
|
+
const babelOptions = (0, utils_1.getBabelOptions)({
|
|
44
65
|
isServer: true,
|
|
45
|
-
babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
|
|
66
|
+
babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
|
|
46
67
|
});
|
|
47
|
-
const extractedCodeTranslations = await translationsExtractor_1.extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions);
|
|
48
|
-
const defaultCodeMessages = await translations_1.getPluginsDefaultCodeTranslationMessages(plugins);
|
|
49
|
-
const codeTranslations = translations_1.applyDefaultCodeTranslations({
|
|
68
|
+
const extractedCodeTranslations = await (0, translationsExtractor_1.extractSiteSourceCodeTranslations)(siteDir, plugins, babelOptions, await getExtraSourceCodeFilePaths());
|
|
69
|
+
const defaultCodeMessages = await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins);
|
|
70
|
+
const codeTranslations = (0, translations_1.applyDefaultCodeTranslations)({
|
|
50
71
|
extractedCodeTranslations,
|
|
51
72
|
defaultCodeMessages,
|
|
52
73
|
});
|
|
53
|
-
await translations_1.writeCodeTranslations({
|
|
74
|
+
await (0, translations_1.writeCodeTranslations)({ localizationDir }, codeTranslations, options);
|
|
54
75
|
await Promise.all(plugins.map(async (plugin) => {
|
|
55
|
-
await writePluginTranslationFiles({
|
|
76
|
+
await writePluginTranslationFiles({ localizationDir, plugin, options });
|
|
56
77
|
}));
|
|
57
78
|
}
|
|
58
|
-
exports.
|
|
79
|
+
exports.writeTranslations = writeTranslations;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
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
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
7
|
+
export { build } from './commands/build';
|
|
8
|
+
export { clear } from './commands/clear';
|
|
9
|
+
export { deploy } from './commands/deploy';
|
|
10
|
+
export { externalCommand } from './commands/external';
|
|
11
|
+
export { serve } from './commands/serve';
|
|
12
|
+
export { start } from './commands/start';
|
|
13
|
+
export { swizzle } from './commands/swizzle';
|
|
14
|
+
export { writeHeadingIds } from './commands/writeHeadingIds';
|
|
15
|
+
export { writeTranslations } from './commands/writeTranslations';
|
package/lib/index.js
CHANGED
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.writeTranslations = exports.writeHeadingIds = exports.swizzle = exports.start = exports.serve = exports.externalCommand = exports.deploy = exports.clear = exports.build = void 0;
|
|
10
10
|
var build_1 = require("./commands/build");
|
|
11
|
-
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
var swizzle_1 = require("./commands/swizzle");
|
|
15
|
-
Object.defineProperty(exports, "swizzle", { enumerable: true, get: function () { return __importDefault(swizzle_1).default; } });
|
|
11
|
+
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
12
|
+
var clear_1 = require("./commands/clear");
|
|
13
|
+
Object.defineProperty(exports, "clear", { enumerable: true, get: function () { return clear_1.clear; } });
|
|
16
14
|
var deploy_1 = require("./commands/deploy");
|
|
17
|
-
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return
|
|
15
|
+
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
18
16
|
var external_1 = require("./commands/external");
|
|
19
|
-
Object.defineProperty(exports, "externalCommand", { enumerable: true, get: function () { return
|
|
17
|
+
Object.defineProperty(exports, "externalCommand", { enumerable: true, get: function () { return external_1.externalCommand; } });
|
|
20
18
|
var serve_1 = require("./commands/serve");
|
|
21
|
-
Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return
|
|
22
|
-
var
|
|
23
|
-
Object.defineProperty(exports, "
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "
|
|
19
|
+
Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return serve_1.serve; } });
|
|
20
|
+
var start_1 = require("./commands/start");
|
|
21
|
+
Object.defineProperty(exports, "start", { enumerable: true, get: function () { return start_1.start; } });
|
|
22
|
+
var swizzle_1 = require("./commands/swizzle");
|
|
23
|
+
Object.defineProperty(exports, "swizzle", { enumerable: true, get: function () { return swizzle_1.swizzle; } });
|
|
26
24
|
var writeHeadingIds_1 = require("./commands/writeHeadingIds");
|
|
27
|
-
Object.defineProperty(exports, "writeHeadingIds", { enumerable: true, get: function () { return
|
|
25
|
+
Object.defineProperty(exports, "writeHeadingIds", { enumerable: true, get: function () { return writeHeadingIds_1.writeHeadingIds; } });
|
|
26
|
+
var writeTranslations_1 = require("./commands/writeTranslations");
|
|
27
|
+
Object.defineProperty(exports, "writeTranslations", { enumerable: true, get: function () { return writeTranslations_1.writeTranslations; } });
|
|
@@ -4,26 +4,13 @@
|
|
|
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 { RouteConfig, ReportingSeverity } from '@docusaurus/types';
|
|
8
|
-
declare type BrokenLink = {
|
|
9
|
-
link: string;
|
|
10
|
-
resolvedLink: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function getAllBrokenLinks({ allCollectedLinks, routes, }: {
|
|
13
|
-
allCollectedLinks: Record<string, string[]>;
|
|
14
|
-
routes: RouteConfig[];
|
|
15
|
-
}): Record<string, BrokenLink[]>;
|
|
16
|
-
export declare function getBrokenLinksErrorMessage(allBrokenLinks: Record<string, BrokenLink[]>): string | undefined;
|
|
17
|
-
export declare function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, }: {
|
|
18
|
-
baseUrl: string;
|
|
19
|
-
outDir: string;
|
|
20
|
-
allCollectedLinks: Record<string, string[]>;
|
|
21
|
-
}): Promise<Record<string, string[]>>;
|
|
7
|
+
import type { RouteConfig, ReportingSeverity } from '@docusaurus/types';
|
|
22
8
|
export declare function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }: {
|
|
23
|
-
allCollectedLinks:
|
|
9
|
+
allCollectedLinks: {
|
|
10
|
+
[location: string]: string[];
|
|
11
|
+
};
|
|
24
12
|
onBrokenLinks: ReportingSeverity;
|
|
25
13
|
routes: RouteConfig[];
|
|
26
14
|
baseUrl: string;
|
|
27
15
|
outDir: string;
|
|
28
16
|
}): Promise<void>;
|
|
29
|
-
export {};
|