@docusaurus/core 2.0.0-beta.18 → 2.0.0-beta.19
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 +12 -7
- package/bin/docusaurus.mjs +21 -72
- package/lib/client/.eslintrc.js +2 -3
- package/lib/client/App.d.ts +1 -1
- package/lib/client/App.js +9 -5
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → BaseUrlIssueBanner/index.d.ts} +10 -5
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +14 -9
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +34 -0
- package/lib/client/LinksCollector.js +1 -2
- package/lib/client/PendingNavigation.d.ts +8 -17
- package/lib/client/PendingNavigation.js +39 -70
- package/lib/client/clientEntry.js +1 -2
- package/lib/client/docusaurus.d.ts +5 -5
- package/lib/client/docusaurus.js +25 -29
- package/lib/client/exports/BrowserOnly.d.ts +3 -4
- package/lib/client/exports/BrowserOnly.js +1 -1
- package/lib/client/exports/ComponentCreator.js +51 -46
- package/lib/client/exports/ErrorBoundary.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +16 -39
- package/lib/client/exports/Link.d.ts +3 -15
- package/lib/client/exports/Link.js +21 -26
- package/lib/client/exports/useBaseUrl.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +3 -3
- package/lib/client/exports/useGlobalData.js +5 -5
- package/lib/client/flat.d.ts +10 -2
- package/lib/client/flat.js +11 -3
- package/lib/client/normalizeLocation.js +14 -5
- package/lib/client/prefetch.js +7 -25
- package/lib/client/preload.d.ts +1 -3
- package/lib/client/preload.js +2 -2
- package/lib/client/routeContext.js +1 -1
- package/lib/client/serverEntry.js +12 -11
- package/lib/client/theme-fallback/Error/index.js +2 -0
- package/lib/client/theme-fallback/Loading/index.js +2 -0
- package/lib/client/theme-fallback/NotFound/index.js +2 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +35 -15
- package/lib/commands/clear.d.ts +1 -1
- package/lib/commands/clear.js +3 -2
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +12 -9
- package/lib/commands/external.d.ts +1 -1
- package/lib/commands/external.js +5 -6
- package/lib/commands/serve.d.ts +7 -2
- package/lib/commands/serve.js +12 -12
- package/lib/commands/start.d.ts +8 -2
- package/lib/commands/start.js +14 -9
- package/lib/commands/swizzle/actions.d.ts +2 -2
- package/lib/commands/swizzle/actions.js +5 -4
- package/lib/commands/swizzle/common.d.ts +3 -3
- package/lib/commands/swizzle/components.js +41 -3
- package/lib/commands/swizzle/config.js +14 -11
- package/lib/commands/swizzle/context.js +6 -10
- package/lib/commands/swizzle/index.d.ts +2 -2
- package/lib/commands/swizzle/index.js +4 -3
- package/lib/commands/writeHeadingIds.d.ts +1 -1
- package/lib/commands/writeHeadingIds.js +5 -8
- package/lib/commands/writeTranslations.d.ts +3 -4
- package/lib/commands/writeTranslations.js +7 -9
- package/lib/index.d.ts +9 -10
- package/lib/index.js +18 -19
- package/lib/server/brokenLinks.js +1 -2
- package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +5 -1
- package/lib/server/{client-modules/index.js → clientModules.js} +6 -1
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +11 -6
- package/lib/server/configValidation.js +6 -5
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/{choosePort.js → server/getHostPort.js} +21 -35
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +2 -11
- package/lib/server/i18n.js +4 -19
- package/lib/server/index.d.ts +28 -13
- package/lib/server/index.js +42 -210
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +8 -7
- package/lib/server/plugins/index.js +59 -134
- package/lib/server/plugins/init.d.ts +6 -19
- package/lib/server/plugins/init.js +16 -68
- package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
- package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
- package/lib/server/plugins/pluginIds.d.ts +4 -0
- package/lib/server/plugins/pluginIds.js +4 -2
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/{presets/index.js → plugins/presets.js} +14 -6
- package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +3 -1
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +112 -0
- package/lib/server/routes.d.ts +42 -8
- package/lib/server/routes.js +150 -92
- package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
- package/lib/server/{versions/index.js → siteMetadata.js} +36 -3
- package/lib/server/translations/translations.d.ts +5 -13
- package/lib/server/translations/translations.js +5 -8
- package/lib/server/translations/translationsExtractor.d.ts +2 -4
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +0 -3
- package/lib/webpack/base.js +8 -25
- package/lib/webpack/client.js +1 -1
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +2 -2
- package/lib/webpack/plugins/WaitPlugin.d.ts +2 -2
- package/lib/webpack/server.d.ts +2 -2
- package/lib/webpack/server.js +5 -3
- package/lib/webpack/utils.d.ts +3 -3
- package/lib/webpack/utils.js +3 -3
- package/package.json +33 -36
- package/lib/choosePort.d.ts +0 -11
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -9
- package/lib/client/client-lifecycles-dispatcher.js +0 -23
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/commandUtils.d.ts +0 -9
- package/lib/commands/commandUtils.js +0 -21
- package/lib/server/duplicateRoutes.d.ts +0 -8
- package/lib/server/duplicateRoutes.js +0 -42
- package/lib/server/html-tags/htmlTags.d.ts +0 -7
- package/lib/server/html-tags/htmlTags.js +0 -38
- package/lib/server/html-tags/index.d.ts +0 -8
- package/lib/server/html-tags/index.js +0 -42
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/themes/alias.d.ts +0 -9
- package/lib/server/themes/alias.js +0 -50
- package/lib/server/themes/index.d.ts +0 -12
- package/lib/server/themes/index.js +0 -47
|
@@ -1,9 +0,0 @@
|
|
|
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 { HostPortCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export declare function getCLIOptionHost(hostOption: HostPortCLIOptions['host']): string;
|
|
9
|
-
export declare function getCLIOptionPort(portOption: HostPortCLIOptions['port'], host: string): Promise<number | null>;
|
|
@@ -1,21 +0,0 @@
|
|
|
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.getCLIOptionPort = exports.getCLIOptionHost = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const choosePort_1 = tslib_1.__importDefault(require("../choosePort"));
|
|
12
|
-
const utils_1 = require("@docusaurus/utils");
|
|
13
|
-
function getCLIOptionHost(hostOption) {
|
|
14
|
-
return hostOption ?? 'localhost';
|
|
15
|
-
}
|
|
16
|
-
exports.getCLIOptionHost = getCLIOptionHost;
|
|
17
|
-
async function getCLIOptionPort(portOption, host) {
|
|
18
|
-
const basePort = portOption ? parseInt(portOption, 10) : utils_1.DEFAULT_PORT;
|
|
19
|
-
return (0, choosePort_1.default)(host, basePort);
|
|
20
|
-
}
|
|
21
|
-
exports.getCLIOptionPort = getCLIOptionPort;
|
|
@@ -1,8 +0,0 @@
|
|
|
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 { ReportingSeverity, RouteConfig } from '@docusaurus/types';
|
|
8
|
-
export declare function handleDuplicateRoutes(pluginsRouteConfigs: RouteConfig[], onDuplicateRoutes: ReportingSeverity): void;
|
|
@@ -1,42 +0,0 @@
|
|
|
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.handleDuplicateRoutes = void 0;
|
|
10
|
-
const utils_1 = require("@docusaurus/utils");
|
|
11
|
-
const utils_2 = require("./utils");
|
|
12
|
-
function getAllDuplicateRoutes(pluginsRouteConfigs) {
|
|
13
|
-
const allRoutes = (0, utils_2.getAllFinalRoutes)(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
|
|
14
|
-
const seenRoutes = new Set();
|
|
15
|
-
return allRoutes.filter((route) => {
|
|
16
|
-
if (seenRoutes.has(route)) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
seenRoutes.add(route);
|
|
20
|
-
return false;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function getDuplicateRoutesMessage(allDuplicateRoutes) {
|
|
24
|
-
const message = allDuplicateRoutes
|
|
25
|
-
.map((duplicateRoute) => `- Attempting to create page at ${duplicateRoute}, but a page already exists at this route.`)
|
|
26
|
-
.join('\n');
|
|
27
|
-
return message;
|
|
28
|
-
}
|
|
29
|
-
function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
|
|
30
|
-
if (onDuplicateRoutes === 'ignore') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const duplicatePaths = getAllDuplicateRoutes(pluginsRouteConfigs);
|
|
34
|
-
const message = getDuplicateRoutesMessage(duplicatePaths);
|
|
35
|
-
if (message) {
|
|
36
|
-
const finalMessage = `Duplicate routes found!
|
|
37
|
-
${message}
|
|
38
|
-
This could lead to non-deterministic routing behavior.`;
|
|
39
|
-
(0, utils_1.reportMessage)(finalMessage, onDuplicateRoutes);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.handleDuplicateRoutes = handleDuplicateRoutes;
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
export default function htmlTagObjectToString(tagDefinition: unknown): string;
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
const tslib_1 = require("tslib");
|
|
10
|
-
const html_tags_1 = tslib_1.__importDefault(require("html-tags"));
|
|
11
|
-
const void_1 = tslib_1.__importDefault(require("html-tags/void"));
|
|
12
|
-
const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
|
|
13
|
-
function assertIsHtmlTagObject(val) {
|
|
14
|
-
if (typeof val !== 'object' || !val) {
|
|
15
|
-
throw new Error(`"${val}" is not a valid HTML tag object.`);
|
|
16
|
-
}
|
|
17
|
-
if (typeof val.tagName !== 'string') {
|
|
18
|
-
throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function htmlTagObjectToString(tagDefinition) {
|
|
22
|
-
assertIsHtmlTagObject(tagDefinition);
|
|
23
|
-
if (html_tags_1.default.indexOf(tagDefinition.tagName) === -1) {
|
|
24
|
-
throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
|
|
25
|
-
}
|
|
26
|
-
const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
|
|
27
|
-
const tagAttributes = tagDefinition.attributes ?? {};
|
|
28
|
-
const attributes = Object.keys(tagAttributes)
|
|
29
|
-
.filter((attributeName) => tagAttributes[attributeName] !== false)
|
|
30
|
-
.map((attributeName) => {
|
|
31
|
-
if (tagAttributes[attributeName] === true) {
|
|
32
|
-
return attributeName;
|
|
33
|
-
}
|
|
34
|
-
return `${attributeName}="${(0, escape_html_1.default)(tagAttributes[attributeName])}"`;
|
|
35
|
-
});
|
|
36
|
-
return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${(!isVoidTag && tagDefinition.innerHTML) || ''}${isVoidTag ? '' : `</${tagDefinition.tagName}>`}`;
|
|
37
|
-
}
|
|
38
|
-
exports.default = htmlTagObjectToString;
|
|
@@ -1,8 +0,0 @@
|
|
|
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 { InjectedHtmlTags, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
-
export declare function loadHtmlTags(plugins: LoadedPlugin[]): InjectedHtmlTags;
|
|
@@ -1,42 +0,0 @@
|
|
|
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.loadHtmlTags = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const htmlTags_1 = tslib_1.__importDefault(require("./htmlTags"));
|
|
12
|
-
function toString(val) {
|
|
13
|
-
return typeof val === 'string' ? val : (0, htmlTags_1.default)(val);
|
|
14
|
-
}
|
|
15
|
-
function createHtmlTagsString(tags) {
|
|
16
|
-
return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
|
|
17
|
-
}
|
|
18
|
-
function loadHtmlTags(plugins) {
|
|
19
|
-
const htmlTags = plugins.reduce((acc, plugin) => {
|
|
20
|
-
if (!plugin.injectHtmlTags) {
|
|
21
|
-
return acc;
|
|
22
|
-
}
|
|
23
|
-
const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) ?? {};
|
|
24
|
-
return {
|
|
25
|
-
headTags: headTags
|
|
26
|
-
? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
|
|
27
|
-
: acc.headTags,
|
|
28
|
-
preBodyTags: preBodyTags
|
|
29
|
-
? `${acc.preBodyTags}\n${createHtmlTagsString(preBodyTags)}`
|
|
30
|
-
: acc.preBodyTags,
|
|
31
|
-
postBodyTags: postBodyTags
|
|
32
|
-
? `${acc.postBodyTags}\n${createHtmlTagsString(postBodyTags)}`
|
|
33
|
-
: acc.postBodyTags,
|
|
34
|
-
};
|
|
35
|
-
}, { headTags: '', preBodyTags: '', postBodyTags: '' });
|
|
36
|
-
return {
|
|
37
|
-
headTags: htmlTags.headTags.trim(),
|
|
38
|
-
preBodyTags: htmlTags.preBodyTags.trim(),
|
|
39
|
-
postBodyTags: htmlTags.postBodyTags.trim(),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.loadHtmlTags = loadHtmlTags;
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
const utils_common_1 = require("@docusaurus/utils-common");
|
|
10
|
-
function applyRouteTrailingSlash(route, params) {
|
|
11
|
-
return {
|
|
12
|
-
...route,
|
|
13
|
-
path: (0, utils_common_1.applyTrailingSlash)(route.path, params),
|
|
14
|
-
...(route.routes && {
|
|
15
|
-
routes: route.routes.map((subroute) => applyRouteTrailingSlash(subroute, params)),
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.default = applyRouteTrailingSlash;
|
|
@@ -1,11 +0,0 @@
|
|
|
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 { LoadContext, PluginConfig } from '@docusaurus/types';
|
|
8
|
-
export default function loadPresets(context: LoadContext): Promise<{
|
|
9
|
-
plugins: PluginConfig[];
|
|
10
|
-
themes: PluginConfig[];
|
|
11
|
-
}>;
|
|
@@ -1,9 +0,0 @@
|
|
|
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 { ThemeAliases } from '@docusaurus/types';
|
|
8
|
-
export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
|
|
9
|
-
export default function themeAlias(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
|
|
@@ -1,50 +0,0 @@
|
|
|
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.sortAliases = void 0;
|
|
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"));
|
|
13
|
-
const utils_1 = require("@docusaurus/utils");
|
|
14
|
-
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
15
|
-
// Order of Webpack aliases is important because one alias can shadow another
|
|
16
|
-
// This ensure @theme/NavbarItem alias is after @theme/NavbarItem/LocaleDropdown
|
|
17
|
-
// See https://github.com/facebook/docusaurus/pull/3922
|
|
18
|
-
// See https://github.com/facebook/docusaurus/issues/5382
|
|
19
|
-
function sortAliases(aliases) {
|
|
20
|
-
// Alphabetical order by default
|
|
21
|
-
const entries = lodash_1.default.sortBy(Object.entries(aliases), ([alias]) => alias);
|
|
22
|
-
// @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
|
|
23
|
-
entries.sort(([alias1], [alias2]) =>
|
|
24
|
-
// eslint-disable-next-line no-nested-ternary
|
|
25
|
-
alias1.includes(`${alias2}/`) ? -1 : alias2.includes(`${alias1}/`) ? 1 : 0);
|
|
26
|
-
return Object.fromEntries(entries);
|
|
27
|
-
}
|
|
28
|
-
exports.sortAliases = sortAliases;
|
|
29
|
-
async function themeAlias(themePath, addOriginalAlias) {
|
|
30
|
-
if (!(await fs_extra_1.default.pathExists(themePath))) {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
|
|
34
|
-
cwd: themePath,
|
|
35
|
-
});
|
|
36
|
-
const aliases = {};
|
|
37
|
-
themeComponentFiles.forEach((relativeSource) => {
|
|
38
|
-
const filePath = path_1.default.join(themePath, relativeSource);
|
|
39
|
-
const fileName = (0, utils_1.fileToPath)(relativeSource);
|
|
40
|
-
const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
|
|
41
|
-
aliases[aliasName] = filePath;
|
|
42
|
-
if (addOriginalAlias) {
|
|
43
|
-
// For swizzled components to access the original.
|
|
44
|
-
const originalAliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme-original', fileName]).replace(/\/$/, ''));
|
|
45
|
-
aliases[originalAliasName] = filePath;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return sortAliases(aliases);
|
|
49
|
-
}
|
|
50
|
-
exports.default = themeAlias;
|
|
@@ -1,12 +0,0 @@
|
|
|
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 { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
-
export declare function loadThemeAliases(themePaths: string[], userThemePaths: string[]): Promise<ThemeAliases>;
|
|
9
|
-
export declare function loadPluginsThemeAliases({ siteDir, plugins, }: {
|
|
10
|
-
siteDir: string;
|
|
11
|
-
plugins: LoadedPlugin[];
|
|
12
|
-
}): Promise<ThemeAliases>;
|
|
@@ -1,47 +0,0 @@
|
|
|
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.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
-
const utils_1 = require("@docusaurus/utils");
|
|
13
|
-
const alias_1 = tslib_1.__importStar(require("./alias"));
|
|
14
|
-
const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
|
|
15
|
-
async function loadThemeAliases(themePaths, userThemePaths) {
|
|
16
|
-
const aliases = {};
|
|
17
|
-
for (const themePath of themePaths) {
|
|
18
|
-
const themeAliases = await (0, alias_1.default)(themePath, true);
|
|
19
|
-
Object.entries(themeAliases).forEach(([aliasKey, alias]) => {
|
|
20
|
-
// If this alias shadows a previous one, use @theme-init to preserve the
|
|
21
|
-
// initial one. @theme-init is only applied once: to the initial theme
|
|
22
|
-
// that provided this component
|
|
23
|
-
if (aliasKey in aliases) {
|
|
24
|
-
const componentName = aliasKey.substring(aliasKey.indexOf('/') + 1);
|
|
25
|
-
const initAlias = `@theme-init/${componentName}`;
|
|
26
|
-
if (!(initAlias in aliases)) {
|
|
27
|
-
aliases[initAlias] = aliases[aliasKey];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
aliases[aliasKey] = alias;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
for (const themePath of userThemePaths) {
|
|
34
|
-
const userThemeAliases = await (0, alias_1.default)(themePath, false);
|
|
35
|
-
Object.assign(aliases, userThemeAliases);
|
|
36
|
-
}
|
|
37
|
-
return (0, alias_1.sortAliases)(aliases);
|
|
38
|
-
}
|
|
39
|
-
exports.loadThemeAliases = loadThemeAliases;
|
|
40
|
-
function loadPluginsThemeAliases({ siteDir, plugins, }) {
|
|
41
|
-
const pluginThemes = plugins
|
|
42
|
-
.map((plugin) => plugin.getThemePath && path_1.default.resolve(plugin.path, plugin.getThemePath()))
|
|
43
|
-
.filter((x) => Boolean(x));
|
|
44
|
-
const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
|
|
45
|
-
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
46
|
-
}
|
|
47
|
-
exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
|