@docusaurus/core 2.0.0-beta.15d451942 → 2.0.0-beta.16

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 (191) hide show
  1. package/bin/beforeCli.mjs +136 -0
  2. package/bin/docusaurus.mjs +280 -0
  3. package/lib/babel/preset.d.ts +8 -3
  4. package/lib/babel/preset.js +8 -7
  5. package/lib/choosePort.js +32 -41
  6. package/lib/client/.eslintrc.js +0 -1
  7. package/lib/client/App.d.ts +1 -2
  8. package/lib/client/App.js +19 -24
  9. package/lib/client/LinksCollector.d.ts +3 -3
  10. package/lib/client/LinksCollector.js +5 -9
  11. package/lib/client/PendingNavigation.d.ts +24 -1
  12. package/lib/client/PendingNavigation.js +5 -7
  13. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +13 -0
  14. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +15 -10
  15. package/lib/client/client-lifecycles-dispatcher.d.ts +2 -5
  16. package/lib/client/client-lifecycles-dispatcher.js +5 -9
  17. package/lib/client/clientEntry.js +11 -5
  18. package/lib/client/docusaurus.d.ts +6 -0
  19. package/lib/client/docusaurus.js +17 -23
  20. package/lib/client/exports/BrowserOnly.d.ts +2 -3
  21. package/lib/client/exports/BrowserOnly.js +14 -7
  22. package/lib/client/exports/ComponentCreator.d.ts +1 -2
  23. package/lib/client/exports/ComponentCreator.js +7 -6
  24. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  25. package/lib/client/exports/ErrorBoundary.js +36 -0
  26. package/lib/client/exports/Head.d.ts +2 -3
  27. package/lib/client/exports/Head.js +3 -4
  28. package/lib/client/exports/Interpolate.d.ts +1 -1
  29. package/lib/client/exports/Interpolate.js +15 -21
  30. package/lib/client/exports/Link.d.ts +11 -5
  31. package/lib/client/exports/Link.js +29 -17
  32. package/lib/client/exports/Translate.d.ts +3 -3
  33. package/lib/client/exports/Translate.js +15 -10
  34. package/lib/client/exports/browserContext.d.ts +11 -0
  35. package/lib/client/exports/browserContext.js +22 -0
  36. package/lib/client/exports/constants.js +1 -11
  37. package/lib/client/exports/docusaurusContext.d.ts +12 -0
  38. package/lib/client/exports/docusaurusContext.js +25 -0
  39. package/lib/client/exports/isInternalUrl.js +1 -1
  40. package/lib/client/exports/renderRoutes.d.ts +1 -2
  41. package/lib/client/exports/renderRoutes.js +1 -2
  42. package/lib/client/exports/router.d.ts +1 -1
  43. package/lib/client/exports/router.js +1 -1
  44. package/lib/client/exports/useBaseUrl.js +3 -5
  45. package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
  46. package/lib/client/exports/useDocusaurusContext.js +3 -9
  47. package/lib/client/exports/useGlobalData.js +4 -8
  48. package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
  49. package/lib/client/exports/useIsBrowser.js +11 -0
  50. package/lib/client/flat.d.ts +2 -2
  51. package/lib/client/flat.js +8 -11
  52. package/lib/client/normalizeLocation.d.ts +2 -5
  53. package/lib/client/normalizeLocation.js +1 -2
  54. package/lib/client/nprogress.css +2 -2
  55. package/lib/client/prefetch.d.ts +1 -2
  56. package/lib/client/prefetch.js +1 -3
  57. package/lib/client/preload.d.ts +3 -2
  58. package/lib/client/preload.js +2 -1
  59. package/lib/client/serverEntry.d.ts +10 -0
  60. package/lib/client/serverEntry.js +90 -142
  61. package/lib/client/theme-fallback/Error/index.d.ts +10 -0
  62. package/lib/client/theme-fallback/Error/index.js +39 -0
  63. package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
  64. package/lib/client/theme-fallback/Layout/index.js +10 -19
  65. package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
  66. package/lib/client/theme-fallback/Loading/index.js +47 -115
  67. package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
  68. package/lib/client/theme-fallback/NotFound/index.js +9 -16
  69. package/lib/{webpack/sharedModuleAliases.d.ts → client/theme-fallback/Root/index.d.ts} +4 -4
  70. package/lib/client/theme-fallback/Root/index.js +2 -7
  71. package/lib/commands/build.d.ts +1 -1
  72. package/lib/commands/build.js +59 -61
  73. package/lib/commands/clear.d.ts +6 -0
  74. package/lib/commands/clear.js +32 -21
  75. package/lib/commands/commandUtils.d.ts +7 -1
  76. package/lib/commands/commandUtils.js +7 -7
  77. package/lib/commands/deploy.d.ts +4 -1
  78. package/lib/commands/deploy.js +115 -71
  79. package/lib/commands/external.d.ts +2 -2
  80. package/lib/commands/external.js +4 -4
  81. package/lib/commands/serve.d.ts +1 -1
  82. package/lib/commands/serve.js +30 -16
  83. package/lib/commands/start.d.ts +1 -1
  84. package/lib/commands/start.js +100 -89
  85. package/lib/commands/swizzle/actions.d.ts +23 -0
  86. package/lib/commands/swizzle/actions.js +102 -0
  87. package/lib/commands/swizzle/common.d.ts +33 -0
  88. package/lib/commands/swizzle/common.js +57 -0
  89. package/lib/commands/swizzle/components.d.ts +29 -0
  90. package/lib/commands/swizzle/components.js +165 -0
  91. package/lib/commands/swizzle/config.d.ts +10 -0
  92. package/lib/commands/swizzle/config.js +77 -0
  93. package/lib/{client/exports → commands/swizzle}/context.d.ts +2 -4
  94. package/lib/commands/swizzle/context.js +30 -0
  95. package/lib/commands/swizzle/index.d.ts +8 -0
  96. package/lib/commands/swizzle/index.js +115 -0
  97. package/lib/commands/swizzle/prompts.d.ts +12 -0
  98. package/lib/commands/swizzle/prompts.js +110 -0
  99. package/lib/commands/swizzle/tables.d.ts +9 -0
  100. package/lib/commands/swizzle/tables.js +116 -0
  101. package/lib/commands/swizzle/themes.d.ts +20 -0
  102. package/lib/commands/swizzle/themes.js +105 -0
  103. package/lib/commands/writeHeadingIds.d.ts +9 -6
  104. package/lib/commands/writeHeadingIds.js +44 -46
  105. package/lib/commands/writeTranslations.d.ts +2 -2
  106. package/lib/commands/writeTranslations.js +36 -14
  107. package/lib/index.d.ts +10 -9
  108. package/lib/index.js +20 -19
  109. package/lib/server/brokenLinks.d.ts +1 -1
  110. package/lib/server/brokenLinks.js +38 -33
  111. package/lib/server/client-modules/index.d.ts +1 -1
  112. package/lib/server/client-modules/index.js +1 -3
  113. package/lib/server/config.d.ts +2 -2
  114. package/lib/server/config.js +10 -7
  115. package/lib/server/configValidation.d.ts +4 -2
  116. package/lib/server/configValidation.js +63 -32
  117. package/lib/server/duplicateRoutes.d.ts +1 -1
  118. package/lib/server/duplicateRoutes.js +10 -6
  119. package/lib/server/html-tags/htmlTags.js +8 -9
  120. package/lib/server/html-tags/index.d.ts +2 -2
  121. package/lib/server/html-tags/index.js +3 -3
  122. package/lib/server/i18n.d.ts +1 -2
  123. package/lib/server/i18n.js +31 -46
  124. package/lib/server/index.d.ts +9 -2
  125. package/lib/server/index.js +165 -87
  126. package/lib/server/loadSetup.d.ts +2 -3
  127. package/lib/server/loadSetup.js +5 -5
  128. package/lib/server/moduleShorthand.d.ts +9 -0
  129. package/lib/server/moduleShorthand.js +46 -0
  130. package/lib/server/plugins/applyRouteTrailingSlash.d.ts +9 -0
  131. package/lib/server/plugins/applyRouteTrailingSlash.js +19 -0
  132. package/lib/server/plugins/index.d.ts +3 -4
  133. package/lib/server/plugins/index.js +53 -37
  134. package/lib/server/plugins/init.d.ts +11 -5
  135. package/lib/server/plugins/init.js +40 -47
  136. package/lib/server/plugins/pluginIds.d.ts +2 -2
  137. package/lib/server/plugins/pluginIds.js +8 -5
  138. package/lib/server/presets/index.d.ts +3 -3
  139. package/lib/server/presets/index.js +14 -14
  140. package/lib/server/routes.d.ts +1 -1
  141. package/lib/server/routes.js +51 -28
  142. package/lib/server/themes/alias.d.ts +3 -2
  143. package/lib/server/themes/alias.js +24 -15
  144. package/lib/server/themes/index.d.ts +6 -2
  145. package/lib/server/themes/index.js +36 -24
  146. package/lib/server/translations/translations.d.ts +10 -5
  147. package/lib/server/translations/translations.js +27 -35
  148. package/lib/server/translations/translationsExtractor.d.ts +9 -4
  149. package/lib/server/translations/translationsExtractor.js +160 -119
  150. package/lib/server/utils.d.ts +9 -3
  151. package/lib/server/utils.js +8 -10
  152. package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
  153. package/lib/server/versions/index.d.ts +3 -4
  154. package/lib/server/versions/index.js +22 -21
  155. package/lib/webpack/base.d.ts +4 -4
  156. package/lib/webpack/base.js +54 -38
  157. package/lib/webpack/client.d.ts +3 -3
  158. package/lib/webpack/client.js +15 -21
  159. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
  160. package/lib/webpack/plugins/ChunkAssetPlugin.js +17 -10
  161. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -6
  162. package/lib/webpack/plugins/CleanWebpackPlugin.js +10 -16
  163. package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
  164. package/lib/webpack/plugins/LogPlugin.js +5 -6
  165. package/lib/webpack/plugins/WaitPlugin.d.ts +1 -1
  166. package/lib/webpack/plugins/WaitPlugin.js +4 -4
  167. package/lib/webpack/server.d.ts +3 -3
  168. package/lib/webpack/server.js +18 -11
  169. package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
  170. package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
  171. package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
  172. package/lib/webpack/utils.d.ts +9 -30
  173. package/lib/webpack/utils.js +58 -171
  174. package/package.json +76 -69
  175. package/bin/docusaurus.js +0 -326
  176. package/lib/.tsbuildinfo +0 -5732
  177. package/lib/client/.tsbuildinfo +0 -4171
  178. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  179. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  180. package/lib/commands/swizzle.d.ts +0 -9
  181. package/lib/commands/swizzle.js +0 -245
  182. package/lib/constants.d.ts +0 -18
  183. package/lib/constants.js +0 -23
  184. package/lib/server/versions/__tests/index.test.js +0 -25
  185. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  186. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  187. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  188. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  189. package/lib/webpack/sharedModuleAliases.js +0 -18
  190. package/tsconfig.client.json +0 -13
  191. package/tsconfig.json +0 -13
@@ -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,105 @@
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 logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
+ const prompts_1 = require("./prompts");
15
+ const common_1 = require("./common");
16
+ function pluginToThemeName(plugin) {
17
+ var _a;
18
+ if (plugin.instance.getThemePath) {
19
+ return ((_a = plugin.instance.version.name) !== null && _a !== void 0 ? _a : 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
+ async 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
+ var _a, _b, _c, _d;
90
+ const pluginInstance = getPluginByThemeName(plugins, themeName);
91
+ const themePath = typescript
92
+ ? (_b = (_a = pluginInstance.instance).getTypeScriptThemePath) === null || _b === void 0 ? void 0 : _b.call(_a)
93
+ : (_d = (_c = pluginInstance.instance).getThemePath) === null || _d === void 0 ? void 0 : _d.call(_c);
94
+ if (!themePath) {
95
+ logger_1.default.warn(typescript
96
+ ? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
97
+ : // This is... technically possible to happen, e.g. returning undefined
98
+ // from getThemePath. Plugins may intentionally or unintentionally
99
+ // disguise as themes?
100
+ logger_1.default.interpolate `name=${themeName} does not provide any theme code.`);
101
+ return process.exit(1);
102
+ }
103
+ return themePath;
104
+ }
105
+ exports.getThemePath = getThemePath;
@@ -4,9 +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 GithubSlugger from 'github-slugger';
8
- export declare function unwrapMarkdownLinks(line: string): string;
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 Slugger } from '@docusaurus/utils';
8
+ declare type Options = {
9
+ maintainCase?: boolean;
10
+ overwrite?: boolean;
11
+ };
12
+ export declare function transformMarkdownHeadingLine(line: string, slugger: Slugger, options?: Options): string;
13
+ export declare function transformMarkdownContent(content: string, options?: Options): string;
14
+ export default function writeHeadingIds(siteDir: string, files?: string[], options?: Options): Promise<void>;
15
+ export {};
@@ -6,105 +6,103 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.transformMarkdownContent = exports.transformMarkdownLine = exports.transformMarkdownHeadingLine = exports.unwrapMarkdownLinks = void 0;
9
+ exports.transformMarkdownContent = exports.transformMarkdownHeadingLine = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
- const github_slugger_1 = tslib_1.__importDefault(require("github-slugger"));
13
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
11
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
13
  const server_1 = require("../server");
15
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
16
- const lodash_1 = require("lodash");
14
+ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
17
15
  const utils_1 = require("@docusaurus/utils");
18
16
  const utils_2 = require("../server/utils");
19
17
  function unwrapMarkdownLinks(line) {
20
- return line.replace(/\[([^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
18
+ return line.replace(/\[(?<alt>[^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
21
19
  }
22
- exports.unwrapMarkdownLinks = unwrapMarkdownLinks;
23
- function addHeadingId(line, slugger) {
20
+ function addHeadingId(line, slugger, maintainCase) {
24
21
  let headingLevel = 0;
25
22
  while (line.charAt(headingLevel) === '#') {
26
23
  headingLevel += 1;
27
24
  }
28
25
  const headingText = line.slice(headingLevel).trimEnd();
29
26
  const headingHashes = line.slice(0, headingLevel);
30
- const slug = slugger.slug(unwrapMarkdownLinks(headingText));
27
+ const slug = slugger
28
+ .slug(unwrapMarkdownLinks(headingText).trim(), { maintainCase })
29
+ .replace(/^-+/, '')
30
+ .replace(/-+$/, '');
31
31
  return `${headingHashes}${headingText} {#${slug}}`;
32
32
  }
33
- function transformMarkdownHeadingLine(line, slugger) {
33
+ function transformMarkdownHeadingLine(line, slugger, options = { maintainCase: false, overwrite: false }) {
34
+ const { maintainCase = false, overwrite = false } = options;
34
35
  if (!line.startsWith('#')) {
35
- throw new Error(`Line is not a markdown heading: ${line}`);
36
+ throw new Error(`Line is not a Markdown heading: ${line}.`);
36
37
  }
37
- const parsedHeading = utils_1.parseMarkdownHeadingId(line);
38
- // Do not process if id is already therer
39
- if (parsedHeading.id) {
38
+ const parsedHeading = (0, utils_1.parseMarkdownHeadingId)(line);
39
+ // Do not process if id is already there
40
+ if (parsedHeading.id && !overwrite) {
40
41
  return line;
41
42
  }
42
- return addHeadingId(line, slugger);
43
+ return addHeadingId(parsedHeading.text, slugger, maintainCase);
43
44
  }
44
45
  exports.transformMarkdownHeadingLine = transformMarkdownHeadingLine;
45
- function transformMarkdownLine(line, slugger) {
46
+ function transformMarkdownLine(line, slugger, options) {
46
47
  // Ignore h1 headings on purpose, as we don't create anchor links for those
47
48
  if (line.startsWith('##')) {
48
- return transformMarkdownHeadingLine(line, slugger);
49
- }
50
- else {
51
- return line;
49
+ return transformMarkdownHeadingLine(line, slugger, options);
52
50
  }
51
+ return line;
53
52
  }
54
- exports.transformMarkdownLine = transformMarkdownLine;
55
- function transformMarkdownLines(lines) {
53
+ function transformMarkdownLines(lines, options) {
56
54
  let inCode = false;
57
- const slugger = new github_slugger_1.default();
55
+ const slugger = (0, utils_1.createSlugger)();
58
56
  return lines.map((line) => {
59
57
  if (line.startsWith('```')) {
60
58
  inCode = !inCode;
61
59
  return line;
62
60
  }
63
- else {
64
- if (inCode) {
65
- return line;
66
- }
67
- return transformMarkdownLine(line, slugger);
61
+ if (inCode) {
62
+ return line;
68
63
  }
64
+ return transformMarkdownLine(line, slugger, options);
69
65
  });
70
66
  }
71
- function transformMarkdownContent(content) {
72
- return transformMarkdownLines(content.split('\n')).join('\n');
67
+ function transformMarkdownContent(content, options) {
68
+ return transformMarkdownLines(content.split('\n'), options).join('\n');
73
69
  }
74
70
  exports.transformMarkdownContent = transformMarkdownContent;
75
- async function transformMarkdownFile(filepath) {
71
+ async function transformMarkdownFile(filepath, options) {
76
72
  const content = await fs_extra_1.default.readFile(filepath, 'utf8');
77
- const updatedContent = transformMarkdownLines(content.split('\n')).join('\n');
73
+ const updatedContent = transformMarkdownLines(content.split('\n'), options).join('\n');
78
74
  if (content !== updatedContent) {
79
75
  await fs_extra_1.default.writeFile(filepath, updatedContent);
80
76
  return filepath;
81
77
  }
82
78
  return undefined;
83
79
  }
84
- // We only handle the "paths to watch" because these are the paths where the markdown files are
85
- // Also we don't want to transform the site md docs that do not belong to a content plugin
86
- // For example ./README.md should not be transformed
80
+ /**
81
+ * We only handle the "paths to watch" because these are the paths where the
82
+ * markdown files are. Also we don't want to transform the site md docs that do
83
+ * not belong to a content plugin. For example ./README.md should not be
84
+ * transformed
85
+ */
87
86
  async function getPathsToWatch(siteDir) {
88
- const context = await server_1.loadContext(siteDir);
89
- const pluginConfigs = server_1.loadPluginConfigs(context);
90
- const plugins = await init_1.default({
87
+ const context = await (0, server_1.loadContext)(siteDir);
88
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
89
+ const plugins = await (0, init_1.default)({
91
90
  pluginConfigs,
92
91
  context,
93
92
  });
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 : []; }));
93
+ return plugins.flatMap((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 : []; });
95
94
  }
96
- async function writeHeadingIds(siteDir) {
97
- const markdownFiles = await utils_2.safeGlobby(await getPathsToWatch(siteDir), {
95
+ async function writeHeadingIds(siteDir, files, options) {
96
+ const markdownFiles = await (0, utils_2.safeGlobby)(files !== null && files !== void 0 ? files : (await getPathsToWatch(siteDir)), {
98
97
  expandDirectories: ['**/*.{md,mdx}'],
99
98
  });
100
- const result = await Promise.all(markdownFiles.map(transformMarkdownFile));
99
+ const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
101
100
  const pathsModified = result.filter(Boolean);
102
101
  if (pathsModified.length) {
103
- console.log(chalk_1.default.green(`Heading ids added to markdown files (${pathsModified.length}/${markdownFiles.length} files):
104
- - ${pathsModified.join('\n- ')}`));
102
+ logger_1.default.success `Heading ids added to Markdown files (number=${`${pathsModified.length}/${markdownFiles.length}`} files): ${pathsModified}`;
105
103
  }
106
104
  else {
107
- console.log(chalk_1.default.yellow(`${markdownFiles.length} markdown files already have explicit heading ids`));
105
+ 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
106
  }
109
107
  }
110
108
  exports.default = writeHeadingIds;
@@ -4,8 +4,8 @@
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 { ConfigOptions } from '@docusaurus/types';
8
- import { WriteTranslationsOptions } from '../server/translations/translations';
7
+ import type { ConfigOptions } from '@docusaurus/types';
8
+ import { type WriteTranslationsOptions } from '../server/translations/translations';
9
9
  export default function writeTranslations(siteDir: string, options: WriteTranslationsOptions & ConfigOptions & {
10
10
  locale?: string;
11
11
  }): Promise<void>;
@@ -1,11 +1,34 @@
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 });
3
9
  const tslib_1 = require("tslib");
10
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
4
11
  const server_1 = require("../server");
5
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
12
+ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
6
13
  const translations_1 = require("../server/translations/translations");
7
14
  const translationsExtractor_1 = require("../server/translations/translationsExtractor");
8
15
  const utils_1 = require("../webpack/utils");
16
+ /**
17
+ * This is a hack, so that @docusaurus/theme-common translations are extracted!
18
+ * A theme doesn't have a way to express that one of its dependency (like
19
+ * @docusaurus/theme-common) also has translations to extract.
20
+ * Instead of introducing a new lifecycle (like `getThemeTranslationPaths()`?)
21
+ * We just make an exception and assume that user is using an official theme
22
+ */
23
+ async function getExtraSourceCodeFilePaths() {
24
+ try {
25
+ const themeCommonSourceDir = path_1.default.dirname(require.resolve('@docusaurus/theme-common/lib'));
26
+ return (0, translationsExtractor_1.globSourceCodeFilePaths)([themeCommonSourceDir]);
27
+ }
28
+ catch {
29
+ return []; // User may not use a Docusaurus official theme? Quite unlikely...
30
+ }
31
+ }
9
32
  async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }) {
10
33
  var _a;
11
34
  if (plugin.getTranslationFiles) {
@@ -14,7 +37,7 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
14
37
  content,
15
38
  });
16
39
  await Promise.all(translationFiles.map(async (translationFile) => {
17
- await translations_1.writePluginTranslations({
40
+ await (0, translations_1.writePluginTranslations)({
18
41
  siteDir,
19
42
  plugin,
20
43
  translationFile,
@@ -26,32 +49,31 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
26
49
  }
27
50
  async function writeTranslations(siteDir, options) {
28
51
  var _a;
29
- const context = await server_1.loadContext(siteDir, {
52
+ const context = await (0, server_1.loadContext)(siteDir, {
30
53
  customConfigFilePath: options.config,
31
54
  locale: options.locale,
32
55
  });
33
- const pluginConfigs = server_1.loadPluginConfigs(context);
34
- const plugins = init_1.default({
56
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
57
+ const plugins = await (0, init_1.default)({
35
58
  pluginConfigs,
36
59
  context,
37
60
  });
38
61
  const locale = (_a = options.locale) !== null && _a !== void 0 ? _a : context.i18n.defaultLocale;
39
62
  if (!context.i18n.locales.includes(locale)) {
40
- throw new Error(`Can't write-translation for locale that is not in the locale configuration file.
41
- Unknown locale=[${locale}].
42
- Available locales=[${context.i18n.locales.join(',')}]`);
63
+ throw new Error(`Can't write-translation for locale "${locale}" that is not in the locale configuration file.
64
+ Available locales are: ${context.i18n.locales.join(',')}.`);
43
65
  }
44
- const babelOptions = utils_1.getBabelOptions({
66
+ const babelOptions = (0, utils_1.getBabelOptions)({
45
67
  isServer: true,
46
- babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
68
+ babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
47
69
  });
48
- const extractedCodeTranslations = await translationsExtractor_1.extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions);
49
- const defaultCodeMessages = await translations_1.getPluginsDefaultCodeTranslationMessages(plugins);
50
- const codeTranslations = translations_1.applyDefaultCodeTranslations({
70
+ const extractedCodeTranslations = await (0, translationsExtractor_1.extractSiteSourceCodeTranslations)(siteDir, plugins, babelOptions, await getExtraSourceCodeFilePaths());
71
+ const defaultCodeMessages = await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins);
72
+ const codeTranslations = (0, translations_1.applyDefaultCodeTranslations)({
51
73
  extractedCodeTranslations,
52
74
  defaultCodeMessages,
53
75
  });
54
- await translations_1.writeCodeTranslations({ siteDir, locale }, codeTranslations, options);
76
+ await (0, translations_1.writeCodeTranslations)({ siteDir, locale }, codeTranslations, options);
55
77
  await Promise.all(plugins.map(async (plugin) => {
56
78
  await writePluginTranslationFiles({ siteDir, plugin, locale, options });
57
79
  }));
package/lib/index.d.ts CHANGED
@@ -4,12 +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
- export { default as build } from './commands/build';
8
- export { default as start } from './commands/start';
9
- export { default as swizzle } from './commands/swizzle';
10
- export { default as deploy } from './commands/deploy';
11
- export { default as externalCommand } from './commands/external';
12
- export { default as serve } from './commands/serve';
13
- export { default as clear } from './commands/clear';
14
- export { default as writeTranslations } from './commands/writeTranslations';
15
- export { default as writeHeadingIds } from './commands/writeHeadingIds';
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, };
package/lib/index.js CHANGED
@@ -6,22 +6,23 @@
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 = exports.writeTranslations = exports.clear = exports.serve = exports.externalCommand = exports.deploy = exports.swizzle = exports.start = exports.build = void 0;
10
- var build_1 = require("./commands/build");
11
- Object.defineProperty(exports, "build", { enumerable: true, get: function () { return __importDefault(build_1).default; } });
12
- var start_1 = require("./commands/start");
13
- Object.defineProperty(exports, "start", { enumerable: true, get: function () { return __importDefault(start_1).default; } });
14
- var swizzle_1 = require("./commands/swizzle");
15
- Object.defineProperty(exports, "swizzle", { enumerable: true, get: function () { return __importDefault(swizzle_1).default; } });
16
- var deploy_1 = require("./commands/deploy");
17
- Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return __importDefault(deploy_1).default; } });
18
- var external_1 = require("./commands/external");
19
- Object.defineProperty(exports, "externalCommand", { enumerable: true, get: function () { return __importDefault(external_1).default; } });
20
- var serve_1 = require("./commands/serve");
21
- Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return __importDefault(serve_1).default; } });
22
- var clear_1 = require("./commands/clear");
23
- Object.defineProperty(exports, "clear", { enumerable: true, get: function () { return __importDefault(clear_1).default; } });
24
- var writeTranslations_1 = require("./commands/writeTranslations");
25
- Object.defineProperty(exports, "writeTranslations", { enumerable: true, get: function () { return __importDefault(writeTranslations_1).default; } });
26
- var writeHeadingIds_1 = require("./commands/writeHeadingIds");
27
- Object.defineProperty(exports, "writeHeadingIds", { enumerable: true, get: function () { return __importDefault(writeHeadingIds_1).default; } });
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 = (0, tslib_1.__importDefault)(require("./commands/build"));
12
+ exports.build = build_1.default;
13
+ const clear_1 = (0, tslib_1.__importDefault)(require("./commands/clear"));
14
+ exports.clear = clear_1.default;
15
+ const deploy_1 = (0, tslib_1.__importDefault)(require("./commands/deploy"));
16
+ exports.deploy = deploy_1.default;
17
+ const external_1 = (0, tslib_1.__importDefault)(require("./commands/external"));
18
+ exports.externalCommand = external_1.default;
19
+ const serve_1 = (0, tslib_1.__importDefault)(require("./commands/serve"));
20
+ exports.serve = serve_1.default;
21
+ const start_1 = (0, tslib_1.__importDefault)(require("./commands/start"));
22
+ exports.start = start_1.default;
23
+ const swizzle_1 = (0, tslib_1.__importDefault)(require("./commands/swizzle"));
24
+ exports.swizzle = swizzle_1.default;
25
+ const writeHeadingIds_1 = (0, tslib_1.__importDefault)(require("./commands/writeHeadingIds"));
26
+ exports.writeHeadingIds = writeHeadingIds_1.default;
27
+ const writeTranslations_1 = (0, tslib_1.__importDefault)(require("./commands/writeTranslations"));
28
+ exports.writeTranslations = writeTranslations_1.default;
@@ -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 { RouteConfig, ReportingSeverity } from '@docusaurus/types';
7
+ import type { RouteConfig, ReportingSeverity } from '@docusaurus/types';
8
8
  declare type BrokenLink = {
9
9
  link: string;
10
10
  resolvedLink: string;
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.handleBrokenLinks = exports.filterExistingFileLinks = exports.getBrokenLinksErrorMessage = exports.getAllBrokenLinks = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const react_router_config_1 = require("react-router-config");
12
- const resolve_pathname_1 = tslib_1.__importDefault(require("resolve-pathname"));
13
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
14
- const lodash_1 = require("lodash");
12
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
15
14
  const utils_1 = require("@docusaurus/utils");
16
15
  const utils_2 = require("./utils");
17
- const path_1 = tslib_1.__importDefault(require("path"));
16
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
+ const combine_promises_1 = (0, tslib_1.__importDefault)(require("combine-promises"));
18
18
  function toReactRouterRoutes(routes) {
19
19
  // @ts-expect-error: types incompatible???
20
20
  return routes;
@@ -29,32 +29,32 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
29
29
  // we must resolve the links before using matchRoutes
30
30
  // resolvePathname is used internally by ReactRouter
31
31
  function resolveLink(link) {
32
- const resolvedLink = resolve_pathname_1.default(onlyPathname(link), pagePath);
32
+ const resolvedLink = (0, utils_1.resolvePathname)(onlyPathname(link), pagePath);
33
33
  return { link, resolvedLink };
34
34
  }
35
35
  function isBrokenLink(link) {
36
36
  const matchedRoutes = [link, decodeURI(link)]
37
- .map((l) => react_router_config_1.matchRoutes(toReactRouterRoutes(routes), l))
37
+ .map((l) => (0, react_router_config_1.matchRoutes)(toReactRouterRoutes(routes), l))
38
38
  .reduce((prev, cur) => prev.concat(cur));
39
39
  return matchedRoutes.length === 0;
40
40
  }
41
41
  return pageLinks.map(resolveLink).filter((l) => isBrokenLink(l.resolvedLink));
42
42
  }
43
- // The route defs can be recursive, and have a parent match-all route
44
- // We don't want to match broken links like /docs/brokenLink against /docs/*
45
- // For this reason, we only consider the "final routes", that do not have subroutes
46
- // We also need to remove the match all 404 route
43
+ /**
44
+ * The route defs can be recursive, and have a parent match-all route. We don't
45
+ * want to match broken links like /docs/brokenLink against /docs/*. For this
46
+ * reason, we only consider the "final routes", that do not have subroutes.
47
+ * We also need to remove the match all 404 route
48
+ */
47
49
  function filterIntermediateRoutes(routesInput) {
48
50
  const routesWithout404 = routesInput.filter((route) => route.path !== '*');
49
- return utils_2.getAllFinalRoutes(routesWithout404);
51
+ return (0, utils_2.getAllFinalRoutes)(routesWithout404);
50
52
  }
51
53
  function getAllBrokenLinks({ allCollectedLinks, routes, }) {
52
54
  const filteredRoutes = filterIntermediateRoutes(routes);
53
- const allBrokenLinks = lodash_1.mapValues(allCollectedLinks, (pageLinks, pagePath) => {
54
- return getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes });
55
- });
55
+ const allBrokenLinks = lodash_1.default.mapValues(allCollectedLinks, (pageLinks, pagePath) => getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes }));
56
56
  // remove pages without any broken link
57
- return lodash_1.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
57
+ return lodash_1.default.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
58
58
  }
59
59
  exports.getAllBrokenLinks = getAllBrokenLinks;
60
60
  function getBrokenLinksErrorMessage(allBrokenLinks) {
@@ -70,12 +70,14 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
70
70
  .map(brokenLinkMessage)
71
71
  .join('\n -> linking to ')}`;
72
72
  }
73
- // If there's a broken link appearing very often, it is probably a broken link on the layout!
74
- // Add an additional message in such case to help user figure this out.
75
- // see https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
73
+ /**
74
+ * If there's a broken link appearing very often, it is probably a broken link
75
+ * on the layout. Add an additional message in such case to help user figure
76
+ * this out. See https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
77
+ */
76
78
  function getLayoutBrokenLinksHelpMessage() {
77
- const flatList = lodash_1.flatten(Object.entries(allBrokenLinks).map(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink }))));
78
- const countedBrokenLinks = lodash_1.countBy(flatList, (item) => item.brokenLink.link);
79
+ const flatList = Object.entries(allBrokenLinks).flatMap(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink })));
80
+ const countedBrokenLinks = lodash_1.default.countBy(flatList, (item) => item.brokenLink.link);
79
81
  const FrequencyThreshold = 5; // Is this a good value?
80
82
  const frequentLinks = Object.entries(countedBrokenLinks)
81
83
  .filter(([, count]) => count >= FrequencyThreshold)
@@ -92,21 +94,20 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
92
94
  `);
93
95
  }
94
96
  exports.getBrokenLinksErrorMessage = getBrokenLinksErrorMessage;
95
- function isExistingFile(filePath) {
97
+ async function isExistingFile(filePath) {
96
98
  try {
97
- return fs_extra_1.default.statSync(filePath).isFile();
99
+ return (await fs_extra_1.default.stat(filePath)).isFile();
98
100
  }
99
- catch (e) {
101
+ catch {
100
102
  return false;
101
103
  }
102
104
  }
103
105
  // If a file actually exist on the file system, we know the link is valid
104
106
  // even if docusaurus does not know about this file, so we don't report it
105
107
  async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, }) {
106
- // not easy to make this async :'(
107
- function linkFileExists(link) {
108
+ async function linkFileExists(link) {
108
109
  // /baseUrl/javadoc/ -> /outDir/javadoc
109
- const baseFilePath = utils_1.removeSuffix(`${outDir}/${utils_1.removePrefix(link, baseUrl)}`, '/');
110
+ const baseFilePath = (0, utils_1.removeSuffix)(`${outDir}/${(0, utils_1.removePrefix)(link, baseUrl)}`, '/');
110
111
  // -> /outDir/javadoc
111
112
  // -> /outDir/javadoc.html
112
113
  // -> /outDir/javadoc/index.html
@@ -115,19 +116,23 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
115
116
  filePathsToTry.push(`${baseFilePath}.html`);
116
117
  filePathsToTry.push(path_1.default.join(baseFilePath, 'index.html'));
117
118
  }
118
- return filePathsToTry.some(isExistingFile);
119
+ for (const file of filePathsToTry) {
120
+ if (await isExistingFile(file)) {
121
+ return true;
122
+ }
123
+ }
124
+ return false;
119
125
  }
120
- return lodash_1.mapValues(allCollectedLinks, (links) => {
121
- return links.filter((link) => !linkFileExists(link));
122
- });
126
+ return (0, combine_promises_1.default)(lodash_1.default.mapValues(allCollectedLinks, async (links) => (await Promise.all(links.map(async (link) => ((await linkFileExists(link)) ? '' : link)))).filter(Boolean)));
123
127
  }
124
128
  exports.filterExistingFileLinks = filterExistingFileLinks;
125
129
  async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }) {
126
130
  if (onBrokenLinks === 'ignore') {
127
131
  return;
128
132
  }
129
- // If we link to a file like /myFile.zip, and the file actually exist for the file system
130
- // it is not a broken link, it may simply be a link to an existing static file...
133
+ // If we link to a file like /myFile.zip, and the file actually exist for the
134
+ // file system. It is not a broken link, it may simply be a link to an
135
+ // existing static file...
131
136
  const allCollectedLinksFiltered = await filterExistingFileLinks({
132
137
  allCollectedLinks,
133
138
  baseUrl,
@@ -139,7 +144,7 @@ async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, bas
139
144
  });
140
145
  const errorMessage = getBrokenLinksErrorMessage(allBrokenLinks);
141
146
  if (errorMessage) {
142
- utils_1.reportMessage(errorMessage, onBrokenLinks);
147
+ (0, utils_1.reportMessage)(errorMessage, onBrokenLinks);
143
148
  }
144
149
  }
145
150
  exports.handleBrokenLinks = handleBrokenLinks;
@@ -4,5 +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 { Plugin } from '@docusaurus/types';
7
+ import type { Plugin } from '@docusaurus/types';
8
8
  export default function loadClientModules(plugins: Plugin<unknown>[]): string[];