@docusaurus/core 0.0.0-4519 → 0.0.0-4525

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 (62) hide show
  1. package/lib/babel/preset.js +5 -4
  2. package/lib/client/App.js +12 -6
  3. package/lib/client/LinksCollector.js +1 -1
  4. package/lib/client/PendingNavigation.d.ts +3 -3
  5. package/lib/client/PendingNavigation.js +3 -3
  6. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +8 -0
  7. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +15 -10
  8. package/lib/client/clientEntry.js +8 -5
  9. package/lib/client/docusaurus.js +5 -3
  10. package/lib/client/exports/BrowserOnly.js +1 -1
  11. package/lib/client/exports/ComponentCreator.js +5 -2
  12. package/lib/client/exports/Head.js +1 -1
  13. package/lib/client/exports/Interpolate.js +9 -12
  14. package/lib/client/exports/Link.js +7 -4
  15. package/lib/client/exports/Translate.js +2 -1
  16. package/lib/client/exports/browserContext.js +3 -2
  17. package/lib/client/exports/docusaurusContext.js +1 -1
  18. package/lib/client/preload.d.ts +2 -1
  19. package/lib/client/preload.js +2 -1
  20. package/lib/client/serverEntry.js +8 -5
  21. package/lib/client/theme-fallback/Error/index.d.ts +11 -0
  22. package/lib/client/theme-fallback/Error/index.js +21 -28
  23. package/lib/client/theme-fallback/Layout/index.d.ts +11 -0
  24. package/lib/client/theme-fallback/Layout/index.js +10 -18
  25. package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
  26. package/lib/client/theme-fallback/Loading/index.js +46 -114
  27. package/lib/client/theme-fallback/NotFound/index.d.ts +9 -0
  28. package/lib/client/theme-fallback/NotFound/index.js +8 -14
  29. package/lib/client/theme-fallback/Root/index.d.ts +11 -0
  30. package/lib/client/theme-fallback/Root/index.js +2 -4
  31. package/lib/commands/build.js +15 -17
  32. package/lib/commands/deploy.js +3 -3
  33. package/lib/commands/external.js +1 -1
  34. package/lib/commands/serve.js +2 -2
  35. package/lib/commands/swizzle.js +5 -3
  36. package/lib/commands/writeHeadingIds.js +11 -12
  37. package/lib/commands/writeTranslations.js +8 -5
  38. package/lib/server/brokenLinks.js +14 -9
  39. package/lib/server/configValidation.d.ts +1 -1
  40. package/lib/server/configValidation.js +2 -1
  41. package/lib/server/duplicateRoutes.js +2 -4
  42. package/lib/server/i18n.js +11 -15
  43. package/lib/server/index.d.ts +1 -1
  44. package/lib/server/index.js +12 -10
  45. package/lib/server/plugins/index.js +6 -6
  46. package/lib/server/plugins/init.js +14 -24
  47. package/lib/server/presets/index.d.ts +2 -2
  48. package/lib/server/presets/index.js +3 -3
  49. package/lib/server/routes.js +2 -1
  50. package/lib/server/themes/index.js +3 -2
  51. package/lib/server/translations/translations.js +2 -4
  52. package/lib/server/translations/translationsExtractor.js +17 -14
  53. package/lib/server/versions/index.js +4 -2
  54. package/lib/webpack/base.js +19 -11
  55. package/lib/webpack/client.js +5 -2
  56. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +11 -0
  57. package/lib/webpack/plugins/ChunkAssetPlugin.js +17 -10
  58. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +4 -3
  59. package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -1
  60. package/lib/webpack/server.js +4 -3
  61. package/lib/webpack/utils.js +8 -9
  62. package/package.json +10 -10
@@ -4,133 +4,65 @@
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
-
8
7
  import React from 'react';
9
-
10
- export default function Loading({error, retry, pastDelay}) {
11
- if (error) {
12
- return (
13
- <div
14
- style={{
15
- align: 'center',
16
- color: '#fff',
17
- backgroundColor: '#fa383e',
18
- borderColor: '#fa383e',
19
- borderStyle: 'solid',
20
- borderRadius: '0.25rem',
21
- borderWidth: '1px',
22
- boxSizing: 'border-box',
23
- display: 'block',
24
- padding: '1rem',
25
- flex: '0 0 50%',
26
- marginLeft: '25%',
27
- marginRight: '25%',
28
- marginTop: '5rem',
29
- maxWidth: '50%',
30
- width: '100%',
31
- }}>
8
+ export default function Loading({ error, retry, pastDelay, }) {
9
+ if (error) {
10
+ return (<div style={{
11
+ textAlign: 'center',
12
+ color: '#fff',
13
+ backgroundColor: '#fa383e',
14
+ borderColor: '#fa383e',
15
+ borderStyle: 'solid',
16
+ borderRadius: '0.25rem',
17
+ borderWidth: '1px',
18
+ boxSizing: 'border-box',
19
+ display: 'block',
20
+ padding: '1rem',
21
+ flex: '0 0 50%',
22
+ marginLeft: '25%',
23
+ marginRight: '25%',
24
+ marginTop: '5rem',
25
+ maxWidth: '50%',
26
+ width: '100%',
27
+ }}>
32
28
  <p>{error.message}</p>
33
29
  <div>
34
30
  <button type="button" onClick={retry}>
35
31
  Retry
36
32
  </button>
37
33
  </div>
38
- </div>
39
- );
40
- }
41
-
42
- if (pastDelay) {
43
- return (
44
- <div
45
- style={{
46
- display: 'flex',
47
- justifyContent: 'center',
48
- alignItems: 'center',
49
- height: '100vh',
50
- }}>
51
- <svg
52
- id="loader"
53
- style={{
54
- width: 128,
55
- height: 110,
56
- position: 'absolute',
57
- top: 'calc(100vh - 64%)',
58
- }}
59
- viewBox="0 0 45 45"
60
- xmlns="http://www.w3.org/2000/svg"
61
- stroke="#61dafb">
62
- <g
63
- fill="none"
64
- fillRule="evenodd"
65
- transform="translate(1 1)"
66
- strokeWidth="2">
34
+ </div>);
35
+ }
36
+ if (pastDelay) {
37
+ return (<div style={{
38
+ display: 'flex',
39
+ justifyContent: 'center',
40
+ alignItems: 'center',
41
+ height: '100vh',
42
+ }}>
43
+ <svg id="loader" style={{
44
+ width: 128,
45
+ height: 110,
46
+ position: 'absolute',
47
+ top: 'calc(100vh - 64%)',
48
+ }} viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#61dafb">
49
+ <g fill="none" fillRule="evenodd" transform="translate(1 1)" strokeWidth="2">
67
50
  <circle cx="22" cy="22" r="6" strokeOpacity="0">
68
- <animate
69
- attributeName="r"
70
- begin="1.5s"
71
- dur="3s"
72
- values="6;22"
73
- calcMode="linear"
74
- repeatCount="indefinite"
75
- />
76
- <animate
77
- attributeName="stroke-opacity"
78
- begin="1.5s"
79
- dur="3s"
80
- values="1;0"
81
- calcMode="linear"
82
- repeatCount="indefinite"
83
- />
84
- <animate
85
- attributeName="stroke-width"
86
- begin="1.5s"
87
- dur="3s"
88
- values="2;0"
89
- calcMode="linear"
90
- repeatCount="indefinite"
91
- />
51
+ <animate attributeName="r" begin="1.5s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
52
+ <animate attributeName="stroke-opacity" begin="1.5s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
53
+ <animate attributeName="stroke-width" begin="1.5s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
92
54
  </circle>
93
55
  <circle cx="22" cy="22" r="6" strokeOpacity="0">
94
- <animate
95
- attributeName="r"
96
- begin="3s"
97
- dur="3s"
98
- values="6;22"
99
- calcMode="linear"
100
- repeatCount="indefinite"
101
- />
102
- <animate
103
- attributeName="stroke-opacity"
104
- begin="3s"
105
- dur="3s"
106
- values="1;0"
107
- calcMode="linear"
108
- repeatCount="indefinite"
109
- />
110
- <animate
111
- attributeName="stroke-width"
112
- begin="3s"
113
- dur="3s"
114
- values="2;0"
115
- calcMode="linear"
116
- repeatCount="indefinite"
117
- />
56
+ <animate attributeName="r" begin="3s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
57
+ <animate attributeName="stroke-opacity" begin="3s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
58
+ <animate attributeName="stroke-width" begin="3s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
118
59
  </circle>
119
60
  <circle cx="22" cy="22" r="8">
120
- <animate
121
- attributeName="r"
122
- begin="0s"
123
- dur="1.5s"
124
- values="6;1;2;3;4;5;6"
125
- calcMode="linear"
126
- repeatCount="indefinite"
127
- />
61
+ <animate attributeName="r" begin="0s" dur="1.5s" values="6;1;2;3;4;5;6" calcMode="linear" repeatCount="indefinite"/>
128
62
  </circle>
129
63
  </g>
130
64
  </svg>
131
- </div>
132
- );
133
- }
134
-
135
- return null;
65
+ </div>);
66
+ }
67
+ return null;
136
68
  }
@@ -0,0 +1,9 @@
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
+ /// <reference types="react" />
8
+ declare function NotFound(): JSX.Element;
9
+ export default NotFound;
@@ -4,25 +4,19 @@
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
-
8
7
  import React from 'react';
9
8
  import Layout from '@theme/Layout';
10
-
11
9
  function NotFound() {
12
- return (
13
- <Layout title="Page Not Found">
14
- <div
15
- style={{
16
- display: 'flex',
17
- justifyContent: 'center',
18
- alignItems: 'center',
19
- height: '50vh',
20
- fontSize: '20px',
10
+ return (<Layout title="Page Not Found">
11
+ <div style={{
12
+ display: 'flex',
13
+ justifyContent: 'center',
14
+ alignItems: 'center',
15
+ height: '50vh',
16
+ fontSize: '20px',
21
17
  }}>
22
18
  <h1>Oops, page not found </h1>
23
19
  </div>
24
- </Layout>
25
- );
20
+ </Layout>);
26
21
  }
27
-
28
22
  export default NotFound;
@@ -0,0 +1,11 @@
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 { ReactNode } from 'react';
8
+ declare function Root({ children }: {
9
+ children: ReactNode;
10
+ }): ReactNode;
11
+ export default Root;
@@ -4,7 +4,6 @@
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
-
8
7
  // Wrapper at the very top of the app, that is applied constantly
9
8
  // and does not depend on current route (unlike the layout)
10
9
  //
@@ -12,8 +11,7 @@
12
11
  // and these providers won't reset state when we navigate
13
12
  //
14
13
  // See https://github.com/facebook/docusaurus/issues/3919
15
- function Root({children}) {
16
- return children;
14
+ function Root({ children }) {
15
+ return children;
17
16
  }
18
-
19
17
  export default Root;
@@ -58,22 +58,20 @@ forceTerminate = true) {
58
58
  if (cliOptions.locale) {
59
59
  return tryToBuildLocale({ locale: cliOptions.locale, isLastLocale: true });
60
60
  }
61
- else {
62
- if (i18n.locales.length > 1) {
63
- logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
64
- }
65
- // We need the default locale to always be the 1st in the list
66
- // If we build it last, it would "erase" the localized sites built in sub-folders
67
- const orderedLocales = [
68
- i18n.defaultLocale,
69
- ...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
70
- ];
71
- const results = await (0, utils_2.mapAsyncSequential)(orderedLocales, (locale) => {
72
- const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
73
- return tryToBuildLocale({ locale, isLastLocale });
74
- });
75
- return results[0];
61
+ if (i18n.locales.length > 1) {
62
+ logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
76
63
  }
64
+ // We need the default locale to always be the 1st in the list. If we build it
65
+ // last, it would "erase" the localized sites built in sub-folders
66
+ const orderedLocales = [
67
+ i18n.defaultLocale,
68
+ ...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
69
+ ];
70
+ const results = await (0, utils_2.mapAsyncSequential)(orderedLocales, (locale) => {
71
+ const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
72
+ return tryToBuildLocale({ locale, isLastLocale });
73
+ });
74
+ return results[0];
77
75
  }
78
76
  exports.default = build;
79
77
  async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
@@ -93,7 +91,8 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
93
91
  plugins: [
94
92
  // Remove/clean build folders before building bundles.
95
93
  new CleanWebpackPlugin_1.default({ verbose: false }),
96
- // Visualize size of webpack output files with an interactive zoomable tree map.
94
+ // Visualize size of webpack output files with an interactive zoomable
95
+ // tree map.
97
96
  cliOptions.bundleAnalyzer && new webpack_bundle_analyzer_1.BundleAnalyzerPlugin(),
98
97
  // Generate client manifests file that will be used for server bundle.
99
98
  new react_loadable_ssr_addon_v5_slorber_1.default({
@@ -153,7 +152,6 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
153
152
  if (!plugin.postBuild) {
154
153
  return;
155
154
  }
156
- // The plugin may reference `this`. We manually bind it again to prevent any bugs.
157
155
  await plugin.postBuild({ ...props, content: plugin.content });
158
156
  }));
159
157
  await (0, brokenLinks_1.handleBrokenLinks)({
@@ -114,8 +114,8 @@ This behavior can have SEO impacts and create relative link issues.
114
114
  shelljs_1.default.echo('Skipping deploy on a pull request.');
115
115
  shelljs_1.default.exit(0);
116
116
  }
117
- // github.io indicates organization repos that deploy via default branch. All others use gh-pages.
118
- // Organization deploys looks like:
117
+ // github.io indicates organization repos that deploy via default branch.
118
+ // All others use gh-pages. Organization deploys looks like:
119
119
  // - Git repo: https://github.com/<organization>/<organization>.github.io
120
120
  // - Site url: https://<organization>.github.io
121
121
  const isGitHubPagesOrganizationDeploy = projectName.includes('.github.io');
@@ -196,7 +196,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
196
196
  }
197
197
  };
198
198
  if (!cliOptions.skipBuild) {
199
- // Build static html files, then push to deploymentBranch branch of specified repo.
199
+ // Build site, then push to deploymentBranch branch of specified repo.
200
200
  try {
201
201
  await runDeploy(await (0, build_1.default)(siteDir, cliOptions, false));
202
202
  }
@@ -11,7 +11,7 @@ const server_1 = require("../server");
11
11
  const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
12
12
  async function externalCommand(cli, siteDir) {
13
13
  const context = await (0, server_1.loadContext)(siteDir);
14
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
14
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
15
15
  const plugins = await (0, init_1.default)({ pluginConfigs, context });
16
16
  // Plugin Lifecycle - extendCli.
17
17
  plugins.forEach((plugin) => {
@@ -44,8 +44,8 @@ async function serve(siteDir, cliOptions) {
44
44
  res.end();
45
45
  return;
46
46
  }
47
- // Remove baseUrl before calling serveHandler
48
- // Reason: /baseUrl/ should serve /build/index.html, not /build/baseUrl/index.html (does not exist)
47
+ // Remove baseUrl before calling serveHandler, because /baseUrl/ should
48
+ // serve /build/index.html, not /build/baseUrl/index.html (does not exist)
49
49
  req.url = (_b = req.url) === null || _b === void 0 ? void 0 : _b.replace(baseUrl, '/');
50
50
  (0, serve_handler_1.default)(req, res, {
51
51
  cleanUrls: true,
@@ -109,7 +109,7 @@ function colorCode(themePath, plugin) {
109
109
  async function swizzle(siteDir, themeName, componentName, typescript, danger) {
110
110
  var _a, _b, _c, _d, _e;
111
111
  const context = await (0, server_1.loadContext)(siteDir);
112
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
112
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
113
113
  const pluginNames = getPluginNames(pluginConfigs);
114
114
  const plugins = await (0, init_1.default)({
115
115
  pluginConfigs,
@@ -185,7 +185,8 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
185
185
  let score = formattedComponentName.length;
186
186
  components.forEach((component) => {
187
187
  if (component.toLowerCase() === formattedComponentName.toLowerCase()) {
188
- // may be components with same lowercase key, try to match closest component
188
+ // may be components with same lowercase key, try to match closest
189
+ // component
189
190
  const currentScore = (0, leven_1.default)(formattedComponentName, component);
190
191
  if (currentScore < score) {
191
192
  score = currentScore;
@@ -202,7 +203,8 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
202
203
  let fromPath = path_1.default.join(themePath, mostSuitableComponent);
203
204
  let toPath = path_1.default.resolve(siteDir, utils_1.THEME_PATH, mostSuitableComponent);
204
205
  // Handle single TypeScript/JavaScript file only.
205
- // E.g: if <fromPath> does not exist, we try to swizzle <fromPath>.(ts|tsx|js) instead
206
+ // E.g: if <fromPath> does not exist, we try to swizzle
207
+ // <fromPath>.(ts|tsx|js) instead
206
208
  if (!fs_extra_1.default.existsSync(fromPath)) {
207
209
  if (fs_extra_1.default.existsSync(`${fromPath}.ts`)) {
208
210
  [fromPath, toPath] = [`${fromPath}.ts`, `${toPath}.ts`];
@@ -48,9 +48,7 @@ function transformMarkdownLine(line, slugger, options) {
48
48
  if (line.startsWith('##')) {
49
49
  return transformMarkdownHeadingLine(line, slugger, options);
50
50
  }
51
- else {
52
- return line;
53
- }
51
+ return line;
54
52
  }
55
53
  function transformMarkdownLines(lines, options) {
56
54
  let inCode = false;
@@ -60,12 +58,10 @@ function transformMarkdownLines(lines, options) {
60
58
  inCode = !inCode;
61
59
  return line;
62
60
  }
63
- else {
64
- if (inCode) {
65
- return line;
66
- }
67
- return transformMarkdownLine(line, slugger, options);
61
+ if (inCode) {
62
+ return line;
68
63
  }
64
+ return transformMarkdownLine(line, slugger, options);
69
65
  });
70
66
  }
71
67
  function transformMarkdownContent(content, options) {
@@ -81,12 +77,15 @@ async function transformMarkdownFile(filepath, options) {
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
87
  const context = await (0, server_1.loadContext)(siteDir);
89
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
88
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
90
89
  const plugins = await (0, init_1.default)({
91
90
  pluginConfigs,
92
91
  context,
@@ -13,10 +13,13 @@ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
13
13
  const translations_1 = require("../server/translations/translations");
14
14
  const translationsExtractor_1 = require("../server/translations/translationsExtractor");
15
15
  const utils_1 = require("../webpack/utils");
16
- // This is a hack, so that @docusaurus/theme-common translations are extracted!
17
- // A theme doesn't have a way to express that one of its dependency (like @docusaurus/theme-common) also has translations to extract
18
- // Instead of introducing a new lifecycle (like plugin.getThemeTranslationPaths() ?)
19
- // We just make an exception and assume that Docusaurus user is using an official theme
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
+ */
20
23
  async function getExtraSourceCodeFilePaths() {
21
24
  try {
22
25
  const themeCommonSourceDir = path_1.default.dirname(require.resolve('@docusaurus/theme-common/lib'));
@@ -50,7 +53,7 @@ async function writeTranslations(siteDir, options) {
50
53
  customConfigFilePath: options.config,
51
54
  locale: options.locale,
52
55
  });
53
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
56
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
54
57
  const plugins = await (0, init_1.default)({
55
58
  pluginConfigs,
56
59
  context,
@@ -39,10 +39,12 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
39
39
  }
40
40
  return pageLinks.map(resolveLink).filter((l) => isBrokenLink(l.resolvedLink));
41
41
  }
42
- // The route defs can be recursive, and have a parent match-all route
43
- // We don't want to match broken links like /docs/brokenLink against /docs/*
44
- // For this reason, we only consider the "final routes", that do not have subroutes
45
- // We also need to remove the match all 404 route
42
+ /**
43
+ * The route defs can be recursive, and have a parent match-all route. We don't
44
+ * want to match broken links like /docs/brokenLink against /docs/*. For this
45
+ * reason, we only consider the "final routes", that do not have subroutes.
46
+ * We also need to remove the match all 404 route
47
+ */
46
48
  function filterIntermediateRoutes(routesInput) {
47
49
  const routesWithout404 = routesInput.filter((route) => route.path !== '*');
48
50
  return (0, utils_2.getAllFinalRoutes)(routesWithout404);
@@ -67,9 +69,11 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
67
69
  .map(brokenLinkMessage)
68
70
  .join('\n -> linking to ')}`;
69
71
  }
70
- // If there's a broken link appearing very often, it is probably a broken link on the layout!
71
- // Add an additional message in such case to help user figure this out.
72
- // see https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
72
+ /**
73
+ * If there's a broken link appearing very often, it is probably a broken link
74
+ * on the layout. Add an additional message in such case to help user figure
75
+ * this out. See https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
76
+ */
73
77
  function getLayoutBrokenLinksHelpMessage() {
74
78
  const flatList = Object.entries(allBrokenLinks).flatMap(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink })));
75
79
  const countedBrokenLinks = (0, lodash_1.countBy)(flatList, (item) => item.brokenLink.link);
@@ -121,8 +125,9 @@ async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, bas
121
125
  if (onBrokenLinks === 'ignore') {
122
126
  return;
123
127
  }
124
- // If we link to a file like /myFile.zip, and the file actually exist for the file system
125
- // it is not a broken link, it may simply be a link to an existing static file...
128
+ // If we link to a file like /myFile.zip, and the file actually exist for the
129
+ // file system. It is not a broken link, it may simply be a link to an
130
+ // existing static file...
126
131
  const allCollectedLinksFiltered = await filterExistingFileLinks({
127
132
  allCollectedLinks,
128
133
  baseUrl,
@@ -7,6 +7,6 @@
7
7
  import type { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
9
  export declare const DEFAULT_I18N_CONFIG: I18nConfig;
10
- export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'baseUrlIssueBanner' | 'staticDirectories'>;
10
+ export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
11
11
  export declare const ConfigSchema: Joi.ObjectSchema<any>;
12
12
  export declare function validateConfig(config: Partial<DocusaurusConfig>): DocusaurusConfig;
@@ -29,6 +29,7 @@ exports.DEFAULT_CONFIG = {
29
29
  themeConfig: {},
30
30
  titleDelimiter: '|',
31
31
  noIndex: false,
32
+ tagline: '',
32
33
  baseUrlIssueBanner: true,
33
34
  staticDirectories: [utils_1.STATIC_DIR_NAME],
34
35
  };
@@ -143,7 +144,7 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
143
144
  type: utils_validation_1.Joi.string(),
144
145
  }).unknown()),
145
146
  clientModules: utils_validation_1.Joi.array().items(utils_validation_1.Joi.string()),
146
- tagline: utils_validation_1.Joi.string().allow(''),
147
+ tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
147
148
  titleDelimiter: utils_validation_1.Joi.string().default('|'),
148
149
  noIndex: utils_validation_1.Joi.bool().default(false),
149
150
  webpack: utils_validation_1.Joi.object({
@@ -16,10 +16,8 @@ function getAllDuplicateRoutes(pluginsRouteConfigs) {
16
16
  if (Object.prototype.hasOwnProperty.call(seenRoutes, route)) {
17
17
  return true;
18
18
  }
19
- else {
20
- seenRoutes[route] = true;
21
- return false;
22
- }
19
+ seenRoutes[route] = true;
20
+ return false;
23
21
  });
24
22
  }
25
23
  exports.getAllDuplicateRoutes = getAllDuplicateRoutes;
@@ -61,22 +61,18 @@ function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
61
61
  ? // By default, we don't localize the path of defaultLocale
62
62
  i18n.currentLocale !== i18n.defaultLocale
63
63
  : options.localizePath;
64
- if (shouldLocalizePath) {
65
- // FS paths need special care, for Windows support
66
- if (pathType === 'fs') {
67
- return path_1.default.join(originalPath, path_1.default.sep, i18n.currentLocale, path_1.default.sep);
68
- }
69
- // Url paths
70
- else if (pathType === 'url') {
71
- return (0, utils_1.normalizeUrl)([originalPath, '/', i18n.currentLocale, '/']);
72
- }
73
- // should never happen
74
- else {
75
- throw new Error(`Unhandled path type "${pathType}".`);
76
- }
77
- }
78
- else {
64
+ if (!shouldLocalizePath) {
79
65
  return originalPath;
80
66
  }
67
+ // FS paths need special care, for Windows support
68
+ if (pathType === 'fs') {
69
+ return path_1.default.join(originalPath, path_1.default.sep, i18n.currentLocale, path_1.default.sep);
70
+ }
71
+ // Url paths
72
+ if (pathType === 'url') {
73
+ return (0, utils_1.normalizeUrl)([originalPath, '/', i18n.currentLocale, '/']);
74
+ }
75
+ // should never happen
76
+ throw new Error(`Unhandled path type "${pathType}".`);
81
77
  }
82
78
  exports.localizePath = localizePath;
@@ -19,5 +19,5 @@ 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): PluginConfig[];
22
+ export declare function loadPluginConfigs(context: LoadContext): Promise<PluginConfig[]>;
23
23
  export declare function load(siteDir: string, options?: LoadContextOptions): Promise<Props>;
@@ -82,8 +82,8 @@ async function loadContext(siteDir, options = {}) {
82
82
  };
83
83
  }
84
84
  exports.loadContext = loadContext;
85
- function loadPluginConfigs(context) {
86
- let { plugins: presetPlugins, themes: presetThemes } = (0, presets_1.default)(context);
85
+ async function loadPluginConfigs(context) {
86
+ let { plugins: presetPlugins, themes: presetThemes } = await (0, presets_1.default)(context);
87
87
  const { siteConfig, siteConfigPath } = context;
88
88
  const require = (0, module_1.createRequire)(siteConfigPath);
89
89
  function normalizeShorthand(pluginConfig, pluginType) {
@@ -150,10 +150,12 @@ function createBootstrapPlugin({ siteConfig, }) {
150
150
  },
151
151
  };
152
152
  }
153
- // Configure Webpack fallback mdx loader for md/mdx files out of content-plugin folders
154
- // Adds a "fallback" mdx loader for mdx files that are not processed by content plugins
155
- // This allows to do things such as importing repo/README.md as a partial from another doc
156
- // Not ideal solution though, but good enough for now
153
+ /**
154
+ * Configure Webpack fallback mdx loader for md/mdx files out of content-plugin
155
+ * folders. Adds a "fallback" mdx loader for mdx files that are not processed by
156
+ * content plugins. This allows to do things such as importing repo/README.md as
157
+ * a partial from another doc. Not ideal solution, but good enough for now
158
+ */
157
159
  function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
158
160
  return {
159
161
  name: 'docusaurus-mdx-fallback-plugin',
@@ -161,9 +163,9 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
161
163
  options: {},
162
164
  version: { type: 'synthetic' },
163
165
  configureWebpack(config, isServer, { getJSLoader }) {
164
- // We need the mdx fallback loader to exclude files that were already processed by content plugins mdx loaders
165
- // This works, but a bit hacky...
166
- // Not sure there's a way to handle that differently in webpack :s
166
+ // We need the mdx fallback loader to exclude files that were already
167
+ // processed by content plugins mdx loaders. This works, but a bit
168
+ // hacky... Not sure there's a way to handle that differently in webpack
167
169
  function getMDXFallbackExcludedPaths() {
168
170
  var _a;
169
171
  const rules = (_a = config === null || config === void 0 ? void 0 : config.module) === null || _a === void 0 ? void 0 : _a.rules;
@@ -203,7 +205,7 @@ async function load(siteDir, options = {}) {
203
205
  const context = await loadContext(siteDir, options);
204
206
  const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, ssrTemplate, codeTranslations, } = context;
205
207
  // Plugins.
206
- const pluginConfigs = loadPluginConfigs(context);
208
+ const pluginConfigs = await loadPluginConfigs(context);
207
209
  const { plugins, pluginsRouteConfigs, globalData, themeConfigTranslated } = await (0, plugins_1.loadPlugins)({ pluginConfigs, context });
208
210
  // Side-effect to replace the untranslated themeConfig by the translated one
209
211
  context.siteConfig.themeConfig = themeConfigTranslated;