@docusaurus/core 0.0.0-4798 → 0.0.0-4799
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/commands/build.d.ts +1 -1
- package/lib/commands/build.js +2 -1
- package/lib/commands/clear.d.ts +1 -1
- package/lib/commands/clear.js +2 -1
- package/lib/commands/deploy.d.ts +1 -1
- package/lib/commands/deploy.js +4 -3
- package/lib/commands/external.d.ts +1 -1
- package/lib/commands/external.js +4 -5
- package/lib/commands/serve.d.ts +1 -1
- package/lib/commands/serve.js +4 -3
- package/lib/commands/start.d.ts +1 -1
- package/lib/commands/start.js +2 -1
- package/lib/commands/swizzle/context.js +4 -7
- package/lib/commands/swizzle/index.d.ts +1 -1
- package/lib/commands/swizzle/index.js +2 -1
- package/lib/commands/writeHeadingIds.d.ts +1 -1
- package/lib/commands/writeHeadingIds.js +4 -7
- package/lib/commands/writeTranslations.d.ts +1 -1
- package/lib/commands/writeTranslations.js +4 -7
- package/lib/index.d.ts +9 -10
- package/lib/index.js +18 -19
- package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +1 -1
- package/lib/server/{client-modules/index.js → clientModules.js} +2 -1
- package/lib/server/config.d.ts +1 -1
- package/lib/server/config.js +2 -1
- package/lib/server/{html-tags/index.d.ts → htmlTags.d.ts} +0 -0
- package/lib/server/htmlTags.js +58 -0
- package/lib/server/i18n.d.ts +0 -8
- package/lib/server/i18n.js +1 -18
- package/lib/server/index.d.ts +1 -2
- package/lib/server/index.js +15 -173
- package/lib/server/{html-tags/htmlTags.d.ts → plugins/configs.d.ts} +2 -1
- package/lib/server/plugins/configs.js +42 -0
- package/lib/server/plugins/index.d.ts +2 -6
- package/lib/server/plugins/index.js +9 -43
- package/lib/server/plugins/init.d.ts +1 -4
- package/lib/server/plugins/init.js +7 -5
- package/lib/server/{presets/index.d.ts → plugins/presets.d.ts} +1 -1
- package/lib/server/{presets/index.js → plugins/presets.js} +2 -1
- package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +2 -1
- package/lib/server/plugins/routeConfig.js +53 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +112 -0
- package/lib/server/routes.d.ts +1 -1
- package/lib/server/routes.js +2 -1
- package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
- package/lib/server/{versions/index.js → siteMetadata.js} +34 -2
- package/lib/server/themes/alias.d.ts +1 -1
- package/lib/server/themes/alias.js +2 -2
- package/lib/server/themes/index.js +3 -3
- package/package.json +10 -10
- package/lib/server/html-tags/htmlTags.js +0 -38
- package/lib/server/html-tags/index.js +0 -42
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
|
@@ -0,0 +1,112 @@
|
|
|
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.createMDXFallbackPlugin = exports.createBootstrapPlugin = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
|
|
13
|
+
/**
|
|
14
|
+
* Make a synthetic plugin to:
|
|
15
|
+
* - Inject site client modules
|
|
16
|
+
* - Inject scripts/stylesheets
|
|
17
|
+
*/
|
|
18
|
+
function createBootstrapPlugin({ siteDir, siteConfig, }) {
|
|
19
|
+
const { stylesheets, scripts, clientModules: siteConfigClientModules, } = siteConfig;
|
|
20
|
+
return {
|
|
21
|
+
name: 'docusaurus-bootstrap-plugin',
|
|
22
|
+
content: null,
|
|
23
|
+
options: {
|
|
24
|
+
id: 'default',
|
|
25
|
+
},
|
|
26
|
+
version: { type: 'synthetic' },
|
|
27
|
+
path: siteDir,
|
|
28
|
+
getClientModules() {
|
|
29
|
+
return siteConfigClientModules;
|
|
30
|
+
},
|
|
31
|
+
injectHtmlTags: () => {
|
|
32
|
+
const stylesheetsTags = stylesheets.map((source) => typeof source === 'string'
|
|
33
|
+
? `<link rel="stylesheet" href="${source}">`
|
|
34
|
+
: {
|
|
35
|
+
tagName: 'link',
|
|
36
|
+
attributes: {
|
|
37
|
+
rel: 'stylesheet',
|
|
38
|
+
...source,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const scriptsTags = scripts.map((source) => typeof source === 'string'
|
|
42
|
+
? `<script src="${source}"></script>`
|
|
43
|
+
: {
|
|
44
|
+
tagName: 'script',
|
|
45
|
+
attributes: {
|
|
46
|
+
...source,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
headTags: [...stylesheetsTags, ...scriptsTags],
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.createBootstrapPlugin = createBootstrapPlugin;
|
|
56
|
+
/**
|
|
57
|
+
* Configure Webpack fallback mdx loader for md/mdx files out of content-plugin
|
|
58
|
+
* folders. Adds a "fallback" mdx loader for mdx files that are not processed by
|
|
59
|
+
* content plugins. This allows to do things such as importing repo/README.md as
|
|
60
|
+
* a partial from another doc. Not ideal solution, but good enough for now
|
|
61
|
+
*/
|
|
62
|
+
function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
63
|
+
return {
|
|
64
|
+
name: 'docusaurus-mdx-fallback-plugin',
|
|
65
|
+
content: null,
|
|
66
|
+
options: {
|
|
67
|
+
id: 'default',
|
|
68
|
+
},
|
|
69
|
+
version: { type: 'synthetic' },
|
|
70
|
+
// Synthetic, the path doesn't matter much
|
|
71
|
+
path: '.',
|
|
72
|
+
configureWebpack(config, isServer, { getJSLoader }) {
|
|
73
|
+
// We need the mdx fallback loader to exclude files that were already
|
|
74
|
+
// processed by content plugins mdx loaders. This works, but a bit
|
|
75
|
+
// hacky... Not sure there's a way to handle that differently in webpack
|
|
76
|
+
function getMDXFallbackExcludedPaths() {
|
|
77
|
+
const rules = config?.module?.rules;
|
|
78
|
+
return rules.flatMap((rule) => {
|
|
79
|
+
const isMDXRule = rule.test instanceof RegExp && rule.test.test('x.mdx');
|
|
80
|
+
return isMDXRule ? rule.include : [];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const mdxLoaderOptions = {
|
|
84
|
+
staticDirs: siteConfig.staticDirectories.map((dir) => path_1.default.resolve(siteDir, dir)),
|
|
85
|
+
siteDir,
|
|
86
|
+
// External MDX files are always meant to be imported as partials
|
|
87
|
+
isMDXPartial: () => true,
|
|
88
|
+
// External MDX files might have front matter, just disable the warning
|
|
89
|
+
isMDXPartialFrontMatterWarningDisabled: true,
|
|
90
|
+
remarkPlugins: [remark_admonitions_1.default],
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
module: {
|
|
94
|
+
rules: [
|
|
95
|
+
{
|
|
96
|
+
test: /\.mdx?$/i,
|
|
97
|
+
exclude: getMDXFallbackExcludedPaths(),
|
|
98
|
+
use: [
|
|
99
|
+
getJSLoader({ isServer }),
|
|
100
|
+
{
|
|
101
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
102
|
+
options: mdxLoaderOptions,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
exports.createMDXFallbackPlugin = createMDXFallbackPlugin;
|
package/lib/server/routes.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { ChunkRegistry, RouteConfig, ChunkNames } from '@docusaurus/types';
|
|
8
|
-
export
|
|
8
|
+
export declare function loadRoutes(pluginsRouteConfigs: RouteConfig[], baseUrl: string): Promise<{
|
|
9
9
|
registry: {
|
|
10
10
|
[chunkName: string]: ChunkRegistry;
|
|
11
11
|
};
|
package/lib/server/routes.js
CHANGED
|
@@ -6,6 +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.loadRoutes = void 0;
|
|
9
10
|
const utils_1 = require("@docusaurus/utils");
|
|
10
11
|
const querystring_1 = require("querystring");
|
|
11
12
|
function indent(str) {
|
|
@@ -127,7 +128,7 @@ ${indent(NotFoundRouteCode)}
|
|
|
127
128
|
routesPaths,
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
|
-
exports.
|
|
131
|
+
exports.loadRoutes = loadRoutes;
|
|
131
132
|
function genRouteChunkNames(
|
|
132
133
|
// TODO instead of passing a mutating the registry, return a registry slice?
|
|
133
134
|
registry, value, prefix, name) {
|
|
@@ -4,6 +4,9 @@
|
|
|
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 { PluginVersionInformation } from '@docusaurus/types';
|
|
8
|
-
export declare function getPackageJsonVersion(packageJsonPath: string): Promise<string | undefined>;
|
|
7
|
+
import type { LoadedPlugin, PluginVersionInformation, DocusaurusSiteMetadata } from '@docusaurus/types';
|
|
9
8
|
export declare function getPluginVersion(pluginPath: string, siteDir: string): Promise<PluginVersionInformation>;
|
|
9
|
+
export declare function loadSiteMetadata({ plugins, siteDir, }: {
|
|
10
|
+
plugins: LoadedPlugin[];
|
|
11
|
+
siteDir: string;
|
|
12
|
+
}): Promise<DocusaurusSiteMetadata>;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.loadSiteMetadata = exports.getPluginVersion = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
14
|
async function getPackageJsonVersion(packageJsonPath) {
|
|
14
15
|
if (await fs_extra_1.default.pathExists(packageJsonPath)) {
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
|
|
@@ -17,7 +18,6 @@ async function getPackageJsonVersion(packageJsonPath) {
|
|
|
17
18
|
}
|
|
18
19
|
return undefined;
|
|
19
20
|
}
|
|
20
|
-
exports.getPackageJsonVersion = getPackageJsonVersion;
|
|
21
21
|
async function getPackageJsonName(packageJsonPath) {
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
|
|
23
23
|
return require(packageJsonPath).name;
|
|
@@ -46,3 +46,35 @@ async function getPluginVersion(pluginPath, siteDir) {
|
|
|
46
46
|
return { type: 'local' };
|
|
47
47
|
}
|
|
48
48
|
exports.getPluginVersion = getPluginVersion;
|
|
49
|
+
/**
|
|
50
|
+
* We want all `@docusaurus/*` packages to have the exact same version!
|
|
51
|
+
* @see https://github.com/facebook/docusaurus/issues/3371
|
|
52
|
+
* @see https://github.com/facebook/docusaurus/pull/3386
|
|
53
|
+
*/
|
|
54
|
+
function checkDocusaurusPackagesVersion(siteMetadata) {
|
|
55
|
+
const { docusaurusVersion } = siteMetadata;
|
|
56
|
+
Object.entries(siteMetadata.pluginVersions).forEach(([plugin, versionInfo]) => {
|
|
57
|
+
if (versionInfo.type === 'package' &&
|
|
58
|
+
versionInfo.name?.startsWith('@docusaurus/') &&
|
|
59
|
+
versionInfo.version &&
|
|
60
|
+
versionInfo.version !== docusaurusVersion) {
|
|
61
|
+
// should we throw instead?
|
|
62
|
+
// It still could work with different versions
|
|
63
|
+
logger_1.default.error `Invalid name=${plugin} version number=${versionInfo.version}.
|
|
64
|
+
All official @docusaurus/* packages should have the exact same version as @docusaurus/core (number=${docusaurusVersion}).
|
|
65
|
+
Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function loadSiteMetadata({ plugins, siteDir, }) {
|
|
70
|
+
const siteMetadata = {
|
|
71
|
+
docusaurusVersion: (await getPackageJsonVersion(path_1.default.join(__dirname, '../../package.json'))),
|
|
72
|
+
siteVersion: await getPackageJsonVersion(path_1.default.join(siteDir, 'package.json')),
|
|
73
|
+
pluginVersions: Object.fromEntries(plugins
|
|
74
|
+
.filter(({ version: { type } }) => type !== 'synthetic')
|
|
75
|
+
.map(({ name, version }) => [name, version])),
|
|
76
|
+
};
|
|
77
|
+
checkDocusaurusPackagesVersion(siteMetadata);
|
|
78
|
+
return siteMetadata;
|
|
79
|
+
}
|
|
80
|
+
exports.loadSiteMetadata = loadSiteMetadata;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ThemeAliases } from '@docusaurus/types';
|
|
8
8
|
export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
|
|
9
|
-
export
|
|
9
|
+
export declare function themeAlias(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
|
|
@@ -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.sortAliases = void 0;
|
|
9
|
+
exports.themeAlias = exports.sortAliases = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -47,4 +47,4 @@ async function themeAlias(themePath, addOriginalAlias) {
|
|
|
47
47
|
});
|
|
48
48
|
return sortAliases(aliases);
|
|
49
49
|
}
|
|
50
|
-
exports.
|
|
50
|
+
exports.themeAlias = themeAlias;
|
|
@@ -10,12 +10,12 @@ exports.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
|
-
const alias_1 =
|
|
13
|
+
const alias_1 = require("./alias");
|
|
14
14
|
const ThemeFallbackDir = path_1.default.join(__dirname, '../../client/theme-fallback');
|
|
15
15
|
async function loadThemeAliases(themePaths, userThemePaths) {
|
|
16
16
|
const aliases = {};
|
|
17
17
|
for (const themePath of themePaths) {
|
|
18
|
-
const themeAliases = await (0, alias_1.
|
|
18
|
+
const themeAliases = await (0, alias_1.themeAlias)(themePath, true);
|
|
19
19
|
Object.entries(themeAliases).forEach(([aliasKey, alias]) => {
|
|
20
20
|
// If this alias shadows a previous one, use @theme-init to preserve the
|
|
21
21
|
// initial one. @theme-init is only applied once: to the initial theme
|
|
@@ -31,7 +31,7 @@ async function loadThemeAliases(themePaths, userThemePaths) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
for (const themePath of userThemePaths) {
|
|
34
|
-
const userThemeAliases = await (0, alias_1.
|
|
34
|
+
const userThemeAliases = await (0, alias_1.themeAlias)(themePath, false);
|
|
35
35
|
Object.assign(aliases, userThemeAliases);
|
|
36
36
|
}
|
|
37
37
|
return (0, alias_1.sortAliases)(aliases);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-4799",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.17.8",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.17.8",
|
|
43
43
|
"@babel/traverse": "^7.17.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4799",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4799",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4799",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4799",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4799",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4799",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.4",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
53
|
"autoprefixer": "^10.4.4",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-4799",
|
|
110
|
+
"@docusaurus/types": "0.0.0-4799",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/nprogress": "^0.2.0",
|
|
113
113
|
"@types/react-dom": "^17.0.14",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "f0feed7df346c16329386f13a7f8522660b97a51"
|
|
132
132
|
}
|
|
@@ -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,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;
|