@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.
Files changed (54) hide show
  1. package/lib/commands/build.d.ts +1 -1
  2. package/lib/commands/build.js +2 -1
  3. package/lib/commands/clear.d.ts +1 -1
  4. package/lib/commands/clear.js +2 -1
  5. package/lib/commands/deploy.d.ts +1 -1
  6. package/lib/commands/deploy.js +4 -3
  7. package/lib/commands/external.d.ts +1 -1
  8. package/lib/commands/external.js +4 -5
  9. package/lib/commands/serve.d.ts +1 -1
  10. package/lib/commands/serve.js +4 -3
  11. package/lib/commands/start.d.ts +1 -1
  12. package/lib/commands/start.js +2 -1
  13. package/lib/commands/swizzle/context.js +4 -7
  14. package/lib/commands/swizzle/index.d.ts +1 -1
  15. package/lib/commands/swizzle/index.js +2 -1
  16. package/lib/commands/writeHeadingIds.d.ts +1 -1
  17. package/lib/commands/writeHeadingIds.js +4 -7
  18. package/lib/commands/writeTranslations.d.ts +1 -1
  19. package/lib/commands/writeTranslations.js +4 -7
  20. package/lib/index.d.ts +9 -10
  21. package/lib/index.js +18 -19
  22. package/lib/server/{client-modules/index.d.ts → clientModules.d.ts} +1 -1
  23. package/lib/server/{client-modules/index.js → clientModules.js} +2 -1
  24. package/lib/server/config.d.ts +1 -1
  25. package/lib/server/config.js +2 -1
  26. package/lib/server/{html-tags/index.d.ts → htmlTags.d.ts} +0 -0
  27. package/lib/server/htmlTags.js +58 -0
  28. package/lib/server/i18n.d.ts +0 -8
  29. package/lib/server/i18n.js +1 -18
  30. package/lib/server/index.d.ts +1 -2
  31. package/lib/server/index.js +15 -173
  32. package/lib/server/{html-tags/htmlTags.d.ts → plugins/configs.d.ts} +2 -1
  33. package/lib/server/plugins/configs.js +42 -0
  34. package/lib/server/plugins/index.d.ts +2 -6
  35. package/lib/server/plugins/index.js +9 -43
  36. package/lib/server/plugins/init.d.ts +1 -4
  37. package/lib/server/plugins/init.js +7 -5
  38. package/lib/server/{presets/index.d.ts → plugins/presets.d.ts} +1 -1
  39. package/lib/server/{presets/index.js → plugins/presets.js} +2 -1
  40. package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +2 -1
  41. package/lib/server/plugins/routeConfig.js +53 -0
  42. package/lib/server/plugins/synthetic.d.ts +20 -0
  43. package/lib/server/plugins/synthetic.js +112 -0
  44. package/lib/server/routes.d.ts +1 -1
  45. package/lib/server/routes.js +2 -1
  46. package/lib/server/{versions/index.d.ts → siteMetadata.d.ts} +5 -2
  47. package/lib/server/{versions/index.js → siteMetadata.js} +34 -2
  48. package/lib/server/themes/alias.d.ts +1 -1
  49. package/lib/server/themes/alias.js +2 -2
  50. package/lib/server/themes/index.js +3 -3
  51. package/package.json +10 -10
  52. package/lib/server/html-tags/htmlTags.js +0 -38
  53. package/lib/server/html-tags/index.js +0 -42
  54. package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { BuildCLIOptions } from '@docusaurus/types';
8
- export default function build(siteDir: string, cliOptions?: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
8
+ export declare function build(siteDir: string, cliOptions?: Partial<BuildCLIOptions>, forceTerminate?: boolean): Promise<string>;
@@ -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.build = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
12
  const copy_webpack_plugin_1 = tslib_1.__importDefault(require("copy-webpack-plugin"));
@@ -73,7 +74,7 @@ forceTerminate = true) {
73
74
  });
74
75
  return results[0];
75
76
  }
76
- exports.default = build;
77
+ exports.build = build;
77
78
  async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
78
79
  process.env.BABEL_ENV = 'production';
79
80
  process.env.NODE_ENV = 'production';
@@ -4,4 +4,4 @@
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 default function clear(siteDir: string): Promise<unknown>;
7
+ export declare function clear(siteDir: string): Promise<unknown>;
@@ -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.clear = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -40,4 +41,4 @@ async function clear(siteDir) {
40
41
  }));
41
42
  return Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
42
43
  }
43
- exports.default = clear;
44
+ exports.clear = clear;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { BuildCLIOptions } from '@docusaurus/types';
8
- export default function deploy(siteDir: string, cliOptions?: Partial<BuildCLIOptions>): Promise<void>;
8
+ export declare function deploy(siteDir: string, cliOptions?: Partial<BuildCLIOptions>): Promise<void>;
@@ -6,13 +6,14 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.deploy = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
12
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
14
  const utils_1 = require("@docusaurus/utils");
14
15
  const server_1 = require("../server");
15
- const build_1 = tslib_1.__importDefault(require("./build"));
16
+ const build_1 = require("./build");
16
17
  const path_1 = tslib_1.__importDefault(require("path"));
17
18
  const os_1 = tslib_1.__importDefault(require("os"));
18
19
  // GIT_PASS env variable should not appear in logs
@@ -172,7 +173,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
172
173
  if (!cliOptions.skipBuild) {
173
174
  // Build site, then push to deploymentBranch branch of specified repo.
174
175
  try {
175
- await runDeploy(await (0, build_1.default)(siteDir, cliOptions, false));
176
+ await runDeploy(await (0, build_1.build)(siteDir, cliOptions, false));
176
177
  }
177
178
  catch (err) {
178
179
  logger_1.default.error('Deployment of the build output failed.');
@@ -184,4 +185,4 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
184
185
  await runDeploy(outDir);
185
186
  }
186
187
  }
187
- exports.default = deploy;
188
+ exports.deploy = deploy;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { CommanderStatic } from 'commander';
8
- export default function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
8
+ export declare function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
@@ -6,16 +6,15 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- const tslib_1 = require("tslib");
9
+ exports.externalCommand = void 0;
10
10
  const server_1 = require("../server");
11
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
11
+ const init_1 = require("../server/plugins/init");
12
12
  async function externalCommand(cli, siteDir) {
13
13
  const context = await (0, server_1.loadContext)(siteDir);
14
- const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
15
- const plugins = await (0, init_1.default)({ pluginConfigs, context });
14
+ const plugins = await (0, init_1.initPlugins)(context);
16
15
  // Plugin Lifecycle - extendCli.
17
16
  plugins.forEach((plugin) => {
18
17
  plugin.extendCli?.(cli);
19
18
  });
20
19
  }
21
- exports.default = externalCommand;
20
+ exports.externalCommand = externalCommand;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { ServeCLIOptions } from '@docusaurus/types';
8
- export default function serve(siteDir: string, cliOptions: ServeCLIOptions): Promise<void>;
8
+ export declare function serve(siteDir: string, cliOptions: ServeCLIOptions): Promise<void>;
@@ -6,18 +6,19 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.serve = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const http_1 = tslib_1.__importDefault(require("http"));
11
12
  const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
12
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
14
  const path_1 = tslib_1.__importDefault(require("path"));
14
15
  const server_1 = require("../server");
15
- const build_1 = tslib_1.__importDefault(require("./build"));
16
+ const build_1 = require("./build");
16
17
  const commandUtils_1 = require("./commandUtils");
17
18
  async function serve(siteDir, cliOptions) {
18
19
  let dir = path_1.default.resolve(siteDir, cliOptions.dir);
19
20
  if (cliOptions.build) {
20
- dir = await (0, build_1.default)(siteDir, {
21
+ dir = await (0, build_1.build)(siteDir, {
21
22
  config: cliOptions.config,
22
23
  outDir: dir,
23
24
  }, false);
@@ -54,4 +55,4 @@ async function serve(siteDir, cliOptions) {
54
55
  logger_1.default.success `Serving path=${cliOptions.dir} directory at url=${servingUrl + baseUrl}.`;
55
56
  server.listen(port);
56
57
  }
57
- exports.default = serve;
58
+ exports.serve = serve;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { StartCLIOptions } from '@docusaurus/types';
8
- export default function start(siteDir: string, cliOptions: Partial<StartCLIOptions>): Promise<void>;
8
+ export declare function start(siteDir: string, cliOptions: Partial<StartCLIOptions>): Promise<void>;
@@ -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.start = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const utils_1 = require("@docusaurus/utils");
11
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -198,4 +199,4 @@ async function start(siteDir, cliOptions) {
198
199
  });
199
200
  });
200
201
  }
201
- exports.default = start;
202
+ exports.start = start;
@@ -7,16 +7,13 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.initSwizzleContext = void 0;
10
- const tslib_1 = require("tslib");
11
10
  const server_1 = require("../../server");
12
- const init_1 = tslib_1.__importStar(require("../../server/plugins/init"));
11
+ const init_1 = require("../../server/plugins/init");
12
+ const configs_1 = require("../../server/plugins/configs");
13
13
  async function initSwizzleContext(siteDir) {
14
14
  const context = await (0, server_1.loadContext)(siteDir);
15
- const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
16
- const plugins = await (0, init_1.default)({
17
- pluginConfigs,
18
- context,
19
- });
15
+ const plugins = await (0, init_1.initPlugins)(context);
16
+ const pluginConfigs = await (0, configs_1.loadPluginConfigs)(context);
20
17
  const pluginsNormalized = await (0, init_1.normalizePluginConfigs)(pluginConfigs, context.siteConfigPath);
21
18
  return {
22
19
  plugins: plugins.map((plugin, pluginIndex) => ({
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { SwizzleOptions } from './common';
8
- export default function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleOptions>): Promise<void>;
8
+ export declare function swizzle(siteDir: string, themeNameParam: string | undefined, componentNameParam: string | undefined, optionsParam: Partial<SwizzleOptions>): Promise<void>;
@@ -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.swizzle = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
11
12
  const themes_1 = require("./themes");
@@ -112,4 +113,4 @@ Ejected name=${componentName} from name=${themeName} to path=${result.createdFil
112
113
  await executeAction();
113
114
  return process.exit(0);
114
115
  }
115
- exports.default = swizzle;
116
+ exports.swizzle = swizzle;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { type WriteHeadingIDOptions } from '@docusaurus/utils';
8
- export default function writeHeadingIds(siteDir: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
8
+ export declare function writeHeadingIds(siteDir: string, files?: string[], options?: WriteHeadingIDOptions): Promise<void>;
@@ -6,12 +6,13 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.writeHeadingIds = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
13
  const utils_1 = require("@docusaurus/utils");
13
14
  const server_1 = require("../server");
14
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
15
+ const init_1 = require("../server/plugins/init");
15
16
  const utils_2 = require("../server/utils");
16
17
  async function transformMarkdownFile(filepath, options) {
17
18
  const content = await fs_extra_1.default.readFile(filepath, 'utf8');
@@ -30,11 +31,7 @@ async function transformMarkdownFile(filepath, options) {
30
31
  */
31
32
  async function getPathsToWatch(siteDir) {
32
33
  const context = await (0, server_1.loadContext)(siteDir);
33
- const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
34
- const plugins = await (0, init_1.default)({
35
- pluginConfigs,
36
- context,
37
- });
34
+ const plugins = await (0, init_1.initPlugins)(context);
38
35
  return plugins.flatMap((plugin) => plugin?.getPathsToWatch?.() ?? []);
39
36
  }
40
37
  async function writeHeadingIds(siteDir, files, options) {
@@ -50,4 +47,4 @@ async function writeHeadingIds(siteDir, files, options) {
50
47
  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.`;
51
48
  }
52
49
  }
53
- exports.default = writeHeadingIds;
50
+ exports.writeHeadingIds = writeHeadingIds;
@@ -6,6 +6,6 @@
6
6
  */
7
7
  import type { ConfigOptions } from '@docusaurus/types';
8
8
  import { type WriteTranslationsOptions } from '../server/translations/translations';
9
- export default function writeTranslations(siteDir: string, options: WriteTranslationsOptions & ConfigOptions & {
9
+ export declare function writeTranslations(siteDir: string, options: WriteTranslationsOptions & ConfigOptions & {
10
10
  locale?: string;
11
11
  }): Promise<void>;
@@ -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.writeTranslations = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const path_1 = tslib_1.__importDefault(require("path"));
11
12
  const server_1 = require("../server");
12
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
13
+ const init_1 = require("../server/plugins/init");
13
14
  const translations_1 = require("../server/translations/translations");
14
15
  const translationsExtractor_1 = require("../server/translations/translationsExtractor");
15
16
  const utils_1 = require("../webpack/utils");
@@ -51,11 +52,7 @@ async function writeTranslations(siteDir, options) {
51
52
  customConfigFilePath: options.config,
52
53
  locale: options.locale,
53
54
  });
54
- const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
55
- const plugins = await (0, init_1.default)({
56
- pluginConfigs,
57
- context,
58
- });
55
+ const plugins = await (0, init_1.initPlugins)(context);
59
56
  const locale = options.locale ?? context.i18n.defaultLocale;
60
57
  if (!context.i18n.locales.includes(locale)) {
61
58
  throw new Error(`Can't write-translation for locale "${locale}" that is not in the locale configuration file.
@@ -76,4 +73,4 @@ Available locales are: ${context.i18n.locales.join(',')}.`);
76
73
  await writePluginTranslationFiles({ siteDir, plugin, locale, options });
77
74
  }));
78
75
  }
79
- exports.default = writeTranslations;
76
+ exports.writeTranslations = writeTranslations;
package/lib/index.d.ts CHANGED
@@ -4,13 +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
- import build from './commands/build';
8
- import clear from './commands/clear';
9
- import deploy from './commands/deploy';
10
- import externalCommand from './commands/external';
11
- import serve from './commands/serve';
12
- import start from './commands/start';
13
- import swizzle from './commands/swizzle';
14
- import writeHeadingIds from './commands/writeHeadingIds';
15
- import writeTranslations from './commands/writeTranslations';
16
- export { build, clear, deploy, externalCommand, serve, start, swizzle, writeHeadingIds, writeTranslations, };
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
@@ -7,22 +7,21 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.writeTranslations = exports.writeHeadingIds = exports.swizzle = exports.start = exports.serve = exports.externalCommand = exports.deploy = exports.clear = exports.build = void 0;
10
- const tslib_1 = require("tslib");
11
- const build_1 = tslib_1.__importDefault(require("./commands/build"));
12
- exports.build = build_1.default;
13
- const clear_1 = tslib_1.__importDefault(require("./commands/clear"));
14
- exports.clear = clear_1.default;
15
- const deploy_1 = tslib_1.__importDefault(require("./commands/deploy"));
16
- exports.deploy = deploy_1.default;
17
- const external_1 = tslib_1.__importDefault(require("./commands/external"));
18
- exports.externalCommand = external_1.default;
19
- const serve_1 = tslib_1.__importDefault(require("./commands/serve"));
20
- exports.serve = serve_1.default;
21
- const start_1 = tslib_1.__importDefault(require("./commands/start"));
22
- exports.start = start_1.default;
23
- const swizzle_1 = tslib_1.__importDefault(require("./commands/swizzle"));
24
- exports.swizzle = swizzle_1.default;
25
- const writeHeadingIds_1 = tslib_1.__importDefault(require("./commands/writeHeadingIds"));
26
- exports.writeHeadingIds = writeHeadingIds_1.default;
27
- const writeTranslations_1 = tslib_1.__importDefault(require("./commands/writeTranslations"));
28
- exports.writeTranslations = writeTranslations_1.default;
10
+ var build_1 = require("./commands/build");
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; } });
14
+ var deploy_1 = require("./commands/deploy");
15
+ Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
16
+ var external_1 = require("./commands/external");
17
+ Object.defineProperty(exports, "externalCommand", { enumerable: true, get: function () { return external_1.externalCommand; } });
18
+ var serve_1 = require("./commands/serve");
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; } });
24
+ var writeHeadingIds_1 = require("./commands/writeHeadingIds");
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; } });
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadedPlugin } from '@docusaurus/types';
8
- export default function loadClientModules(plugins: LoadedPlugin<unknown>[]): string[];
8
+ export declare function loadClientModules(plugins: LoadedPlugin<unknown>[]): string[];
@@ -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.loadClientModules = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const path_1 = tslib_1.__importDefault(require("path"));
11
12
  function loadClientModules(plugins) {
12
13
  return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => path_1.default.resolve(plugin.path, p)) ??
13
14
  []);
14
15
  }
15
- exports.default = loadClientModules;
16
+ exports.loadClientModules = loadClientModules;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { DocusaurusConfig } from '@docusaurus/types';
8
- export default function loadConfig(configPath: string): Promise<DocusaurusConfig>;
8
+ export declare function loadConfig(configPath: string): Promise<DocusaurusConfig>;
@@ -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.loadConfig = void 0;
9
10
  const tslib_1 = require("tslib");
10
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
12
  const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
@@ -20,4 +21,4 @@ async function loadConfig(configPath) {
20
21
  : await importedConfig;
21
22
  return (0, configValidation_1.validateConfig)(loadedConfig);
22
23
  }
23
- exports.default = loadConfig;
24
+ exports.loadConfig = loadConfig;
@@ -0,0 +1,58 @@
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 html_tags_1 = tslib_1.__importDefault(require("html-tags"));
12
+ const void_1 = tslib_1.__importDefault(require("html-tags/void"));
13
+ const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
14
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
15
+ function assertIsHtmlTagObject(val) {
16
+ if (typeof val !== 'object' || !val) {
17
+ throw new Error(`"${val}" is not a valid HTML tag object.`);
18
+ }
19
+ if (typeof val.tagName !== 'string') {
20
+ throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
21
+ }
22
+ if (!html_tags_1.default.includes(val.tagName)) {
23
+ throw new Error(`Error loading ${JSON.stringify(val)}, "${val.tagName}" is not a valid HTML tag.`);
24
+ }
25
+ }
26
+ function htmlTagObjectToString(tag) {
27
+ assertIsHtmlTagObject(tag);
28
+ const isVoidTag = void_1.default.includes(tag.tagName);
29
+ const tagAttributes = tag.attributes ?? {};
30
+ const attributes = Object.keys(tagAttributes)
31
+ .map((attr) => {
32
+ const value = tagAttributes[attr];
33
+ if (typeof value === 'boolean') {
34
+ return value ? attr : undefined;
35
+ }
36
+ return `${attr}="${(0, escape_html_1.default)(value)}"`;
37
+ })
38
+ .filter((str) => Boolean(str));
39
+ const openingTag = `<${[tag.tagName].concat(attributes).join(' ')}>`;
40
+ const innerHTML = (!isVoidTag && tag.innerHTML) || '';
41
+ const closingTag = isVoidTag ? '' : `</${tag.tagName}>`;
42
+ return openingTag + innerHTML + closingTag;
43
+ }
44
+ function createHtmlTagsString(tags) {
45
+ return (Array.isArray(tags) ? tags : [tags])
46
+ .filter(Boolean)
47
+ .map((val) => (typeof val === 'string' ? val : htmlTagObjectToString(val)))
48
+ .join('\n');
49
+ }
50
+ function loadHtmlTags(plugins) {
51
+ const pluginHtmlTags = plugins.map((plugin) => plugin.injectHtmlTags?.({ content: plugin.content }) ?? {});
52
+ const tagTypes = ['headTags', 'preBodyTags', 'postBodyTags'];
53
+ return Object.fromEntries(lodash_1.default.zip(tagTypes, tagTypes.map((type) => pluginHtmlTags
54
+ .map((tags) => createHtmlTagsString(tags[type]))
55
+ .join('\n')
56
+ .trim())));
57
+ }
58
+ exports.loadHtmlTags = loadHtmlTags;
@@ -9,11 +9,3 @@ export declare function getDefaultLocaleConfig(locale: string): I18nLocaleConfig
9
9
  export declare function loadI18n(config: DocusaurusConfig, options: {
10
10
  locale?: string;
11
11
  }): Promise<I18n>;
12
- export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
13
- pathType: 'fs' | 'url';
14
- path: string;
15
- i18n: I18n;
16
- options?: {
17
- localizePath?: boolean;
18
- };
19
- }): string;
@@ -6,10 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.localizePath = exports.loadI18n = exports.getDefaultLocaleConfig = void 0;
9
+ exports.loadI18n = exports.getDefaultLocaleConfig = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = tslib_1.__importDefault(require("path"));
12
- const utils_1 = require("@docusaurus/utils");
13
11
  const rtl_detect_1 = require("rtl-detect");
14
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
13
  function getDefaultLocaleLabel(locale) {
@@ -49,18 +47,3 @@ Note: Docusaurus only support running one locale at a time.`;
49
47
  };
50
48
  }
51
49
  exports.loadI18n = loadI18n;
52
- function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
53
- const shouldLocalizePath =
54
- // By default, we don't localize the path of defaultLocale
55
- options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
56
- if (!shouldLocalizePath) {
57
- return originalPath;
58
- }
59
- // FS paths need special care, for Windows support
60
- if (pathType === 'fs') {
61
- return path_1.default.join(originalPath, i18n.currentLocale);
62
- }
63
- // Url paths; add a trailing slash so it's a valid base URL
64
- return (0, utils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
65
- }
66
- exports.localizePath = localizePath;
@@ -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 { DocusaurusConfig, LoadContext, PluginConfig, Props } from '@docusaurus/types';
7
+ import type { DocusaurusConfig, LoadContext, Props } from '@docusaurus/types';
8
8
  export declare type LoadContextOptions = {
9
9
  customOutDir?: string;
10
10
  customConfigFilePath?: string;
@@ -19,5 +19,4 @@ export declare function loadSiteConfig({ siteDir, customConfigFilePath, }: {
19
19
  siteConfigPath: string;
20
20
  }>;
21
21
  export declare function loadContext(siteDir: string, options?: LoadContextOptions): Promise<LoadContext>;
22
- export declare function loadPluginConfigs(context: LoadContext): Promise<PluginConfig[]>;
23
22
  export declare function load(siteDir: string, options?: LoadContextOptions): Promise<Props>;