@docusaurus/core 2.0.0-beta.fbdeefcac → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/{docusaurus.js → docusaurus.mjs} +79 -118
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -8
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/ExecutionEnvironment.js +7 -8
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +38 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +6 -13
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +108 -146
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/NotFound/index.d.ts} +2 -1
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/client/{exports/context.js → theme-fallback/SiteMetadata/index.d.ts} +2 -2
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +94 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +29 -28
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +109 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +106 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +119 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +46 -25
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +4 -4
- package/lib/server/configValidation.js +86 -41
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -13
- package/lib/server/index.js +83 -165
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +9 -8
- package/lib/server/plugins/index.js +73 -137
- package/lib/server/plugins/init.d.ts +6 -5
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +5 -1
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +14 -19
- package/lib/server/translations/translations.js +40 -72
- package/lib/server/translations/translationsExtractor.d.ts +10 -4
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +45 -57
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +33 -17
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +21 -12
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +3 -2
- package/lib/webpack/utils.d.ts +15 -31
- package/lib/webpack/utils.js +61 -182
- package/package.json +81 -77
- package/bin/beforeCli.js +0 -100
- package/lib/.tsbuildinfo +0 -1
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -1
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -40
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/plugins/applyRouteTrailingSlash.d.ts +0 -9
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -40
- package/lib/server/themes/index.d.ts +0 -12
- package/lib/server/themes/index.js +0 -47
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
|
@@ -4,165 +4,127 @@
|
|
|
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
|
-
import * as eta from 'eta';
|
|
9
7
|
import React from 'react';
|
|
10
|
-
import {StaticRouter} from 'react-router-dom';
|
|
11
|
-
import ReactDOMServer from 'react-dom/server';
|
|
12
|
-
import {Helmet} from 'react-helmet';
|
|
13
|
-
import {getBundles} from 'react-loadable-ssr-addon-v5-slorber';
|
|
14
|
-
import Loadable from 'react-loadable';
|
|
15
|
-
|
|
16
|
-
import {minify} from 'html-minifier-terser';
|
|
17
8
|
import path from 'path';
|
|
18
9
|
import fs from 'fs-extra';
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports
|
|
11
|
+
import _ from 'lodash';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
import * as eta from 'eta';
|
|
14
|
+
import { StaticRouter } from 'react-router-dom';
|
|
15
|
+
import ReactDOMServer from 'react-dom/server';
|
|
16
|
+
import { HelmetProvider } from 'react-helmet-async';
|
|
17
|
+
import { getBundles } from 'react-loadable-ssr-addon-v5-slorber';
|
|
18
|
+
import Loadable from 'react-loadable';
|
|
19
|
+
import { minify } from 'html-minifier-terser';
|
|
22
20
|
import preload from './preload';
|
|
23
|
-
// eslint-disable-next-line import/no-unresolved
|
|
24
21
|
import App from './App';
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
ProvideLinksCollector,
|
|
28
|
-
} from './LinksCollector';
|
|
29
|
-
import chalk from 'chalk';
|
|
30
|
-
// eslint-disable-next-line no-restricted-imports
|
|
31
|
-
import {memoize} from 'lodash';
|
|
32
|
-
|
|
33
|
-
const getCompiledSSRTemplate = memoize((template) => {
|
|
34
|
-
return eta.compile(template.trim(), {
|
|
22
|
+
import { createStatefulLinksCollector, LinksCollectorProvider, } from './LinksCollector';
|
|
23
|
+
const getCompiledSSRTemplate = _.memoize((template) => eta.compile(template.trim(), {
|
|
35
24
|
rmWhitespace: true,
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
25
|
+
}));
|
|
39
26
|
function renderSSRTemplate(ssrTemplate, data) {
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
const compiled = getCompiledSSRTemplate(ssrTemplate);
|
|
28
|
+
return compiled(data, eta.defaultConfig);
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
export default async function render(locals) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
try {
|
|
32
|
+
return await doRender(locals);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
// We are not using logger in this file, because it seems to fail with some
|
|
36
|
+
// compilers / some polyfill methods. This is very likely a bug, but in the
|
|
37
|
+
// long term, when we output native ES modules in SSR, the bug will be gone.
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
console.error(chalk.red(`${chalk.bold('[ERROR]')} Docusaurus server-side rendering could not render static page with path ${chalk.cyan.underline(locals.path)}.`));
|
|
40
|
+
const isNotDefinedErrorRegex = /(?:window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
|
|
41
|
+
if (isNotDefinedErrorRegex.test(err.message)) {
|
|
42
|
+
// prettier-ignore
|
|
43
|
+
console.info(`${chalk.cyan.bold('[INFO]')} It looks like you are using code that should run on the client-side only.
|
|
44
|
+
To get around it, try using ${chalk.cyan('`<BrowserOnly>`')} (${chalk.cyan.underline('https://docusaurus.io/docs/docusaurus-core/#browseronly')}) or ${chalk.cyan('`ExecutionEnvironment`')} (${chalk.cyan.underline('https://docusaurus.io/docs/docusaurus-core/#executionenvironment')}).
|
|
45
|
+
It might also require to wrap your client code in ${chalk.cyan('`useEffect`')} hook and/or import a third-party library dynamically (if any).`);
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
62
48
|
}
|
|
63
|
-
|
|
64
|
-
throw new Error('Server-side rendering fails due to the error above.');
|
|
65
|
-
}
|
|
66
49
|
}
|
|
67
|
-
|
|
68
|
-
// Renderer for static-site-generator-webpack-plugin (async rendering via promises).
|
|
50
|
+
// Renderer for static-site-generator-webpack-plugin (async rendering).
|
|
69
51
|
async function doRender(locals) {
|
|
70
|
-
|
|
71
|
-
routesLocation
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} = locals;
|
|
80
|
-
const location = routesLocation[locals.path];
|
|
81
|
-
await preload(routes, location);
|
|
82
|
-
const modules = new Set();
|
|
83
|
-
const context = {};
|
|
84
|
-
|
|
85
|
-
const linksCollector = createStatefulLinksCollector();
|
|
86
|
-
const appHtml = ReactDOMServer.renderToString(
|
|
52
|
+
const { routesLocation, headTags, preBodyTags, postBodyTags, onLinksCollected, onHeadTagsCollected, baseUrl, ssrTemplate, noIndex, DOCUSAURUS_VERSION, } = locals;
|
|
53
|
+
const location = routesLocation[locals.path];
|
|
54
|
+
await preload(location);
|
|
55
|
+
const modules = new Set();
|
|
56
|
+
const routerContext = {};
|
|
57
|
+
const helmetContext = {};
|
|
58
|
+
const linksCollector = createStatefulLinksCollector();
|
|
59
|
+
const appHtml = ReactDOMServer.renderToString(
|
|
60
|
+
// @ts-expect-error: we are migrating away from react-loadable anyways
|
|
87
61
|
<Loadable.Capture report={(moduleName) => modules.add(moduleName)}>
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
function doMinify() {
|
|
136
|
-
return minify(renderedHtml, {
|
|
137
|
-
removeComments: true,
|
|
138
|
-
removeRedundantAttributes: true,
|
|
139
|
-
removeEmptyAttributes: true,
|
|
140
|
-
removeScriptTypeAttributes: true,
|
|
141
|
-
removeStyleLinkTypeAttributes: true,
|
|
142
|
-
useShortDoctype: true,
|
|
143
|
-
minifyJS: true,
|
|
62
|
+
<HelmetProvider context={helmetContext}>
|
|
63
|
+
<StaticRouter location={location} context={routerContext}>
|
|
64
|
+
<LinksCollectorProvider linksCollector={linksCollector}>
|
|
65
|
+
<App />
|
|
66
|
+
</LinksCollectorProvider>
|
|
67
|
+
</StaticRouter>
|
|
68
|
+
</HelmetProvider>
|
|
69
|
+
</Loadable.Capture>);
|
|
70
|
+
onLinksCollected(location, linksCollector.getCollectedLinks());
|
|
71
|
+
const { helmet } = helmetContext;
|
|
72
|
+
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
73
|
+
const bodyAttributes = helmet.bodyAttributes.toString();
|
|
74
|
+
const metaStrings = [
|
|
75
|
+
helmet.title.toString(),
|
|
76
|
+
helmet.meta.toString(),
|
|
77
|
+
helmet.link.toString(),
|
|
78
|
+
helmet.script.toString(),
|
|
79
|
+
];
|
|
80
|
+
onHeadTagsCollected(location, helmet);
|
|
81
|
+
const metaAttributes = metaStrings.filter(Boolean);
|
|
82
|
+
const { generatedFilesDir } = locals;
|
|
83
|
+
const manifestPath = path.join(generatedFilesDir, 'client-manifest.json');
|
|
84
|
+
// Using readJSON seems to fail for users of some plugins, possibly because of
|
|
85
|
+
// the eval sandbox having a different `Buffer` instance (native one instead
|
|
86
|
+
// of polyfilled one)
|
|
87
|
+
const manifest = (await fs
|
|
88
|
+
.readFile(manifestPath, 'utf-8')
|
|
89
|
+
.then(JSON.parse));
|
|
90
|
+
// Get all required assets for this particular page based on client
|
|
91
|
+
// manifest information.
|
|
92
|
+
const modulesToBeLoaded = [...manifest.entrypoints, ...Array.from(modules)];
|
|
93
|
+
const bundles = getBundles(manifest, modulesToBeLoaded);
|
|
94
|
+
const stylesheets = (bundles.css ?? []).map((b) => b.file);
|
|
95
|
+
const scripts = (bundles.js ?? []).map((b) => b.file);
|
|
96
|
+
const renderedHtml = renderSSRTemplate(ssrTemplate, {
|
|
97
|
+
appHtml,
|
|
98
|
+
baseUrl,
|
|
99
|
+
htmlAttributes,
|
|
100
|
+
bodyAttributes,
|
|
101
|
+
headTags,
|
|
102
|
+
preBodyTags,
|
|
103
|
+
postBodyTags,
|
|
104
|
+
metaAttributes,
|
|
105
|
+
scripts,
|
|
106
|
+
stylesheets,
|
|
107
|
+
noIndex,
|
|
108
|
+
version: DOCUSAURUS_VERSION,
|
|
144
109
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
);
|
|
110
|
+
try {
|
|
111
|
+
if (process.env.SKIP_HTML_MINIFICATION === 'true') {
|
|
112
|
+
return renderedHtml;
|
|
113
|
+
}
|
|
114
|
+
// Minify html with https://github.com/DanielRuf/html-minifier-terser
|
|
115
|
+
return await minify(renderedHtml, {
|
|
116
|
+
removeComments: false,
|
|
117
|
+
removeRedundantAttributes: true,
|
|
118
|
+
removeEmptyAttributes: true,
|
|
119
|
+
removeScriptTypeAttributes: true,
|
|
120
|
+
removeStyleLinkTypeAttributes: true,
|
|
121
|
+
useShortDoctype: true,
|
|
122
|
+
minifyJS: true,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
// prettier-ignore
|
|
127
|
+
console.error(chalk.red(`${chalk.bold('[ERROR]')} Minification of page ${chalk.cyan.underline(locals.path)} failed.`));
|
|
128
|
+
throw err;
|
|
165
129
|
}
|
|
166
|
-
throw e;
|
|
167
|
-
}
|
|
168
130
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Error';
|
|
10
|
+
export default function Error({ error, tryAgain }: Props): JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
// Should we translate theme-fallback?
|
|
8
|
+
/* eslint-disable @docusaurus/no-untranslated-text */
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import Head from '@docusaurus/Head';
|
|
11
|
+
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
12
|
+
import Layout from '@theme/Layout';
|
|
13
|
+
function ErrorDisplay({ error, tryAgain }) {
|
|
14
|
+
return (<div style={{
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
height: '50vh',
|
|
20
|
+
width: '100%',
|
|
21
|
+
fontSize: '20px',
|
|
22
|
+
}}>
|
|
23
|
+
<h1>This page crashed.</h1>
|
|
24
|
+
<p>{error.message}</p>
|
|
25
|
+
<button type="button" onClick={tryAgain}>
|
|
26
|
+
Try again
|
|
27
|
+
</button>
|
|
28
|
+
</div>);
|
|
29
|
+
}
|
|
30
|
+
export default function Error({ error, tryAgain }) {
|
|
31
|
+
// We wrap the error in its own error boundary because the layout can actually
|
|
32
|
+
// throw too... Only the ErrorDisplay component is simple enough to be
|
|
33
|
+
// considered safe to never throw
|
|
34
|
+
return (<ErrorBoundary
|
|
35
|
+
// Note: we display the original error here, not the error that we
|
|
36
|
+
// captured in this extra error boundary
|
|
37
|
+
fallback={() => <ErrorDisplay error={error} tryAgain={tryAgain}/>}>
|
|
38
|
+
<Head>
|
|
39
|
+
<title>Page Error</title>
|
|
40
|
+
</Head>
|
|
41
|
+
<Layout>
|
|
42
|
+
<ErrorDisplay error={error} tryAgain={tryAgain}/>
|
|
43
|
+
</Layout>
|
|
44
|
+
</ErrorBoundary>);
|
|
45
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Layout';
|
|
10
|
+
export default function Layout({ children }: Props): JSX.Element;
|
|
@@ -4,31 +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
|
-
|
|
8
7
|
import React from 'react';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
12
|
-
|
|
13
|
-
function Layout(props) {
|
|
14
|
-
const context = useDocusaurusContext();
|
|
15
|
-
const {siteConfig = {}} = context;
|
|
16
|
-
const {favicon, tagline = '', title: defaultTitle} = siteConfig;
|
|
17
|
-
const {children, title, description} = props;
|
|
18
|
-
const faviconUrl = useBaseUrl(favicon);
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<Head defaultTitle={`${defaultTitle}${tagline ? ` · ${tagline}` : ''}`}>
|
|
22
|
-
{title && <title>{`${title} · ${tagline}`}</title>}
|
|
23
|
-
{favicon && <link rel="shortcut icon" href={faviconUrl} />}
|
|
24
|
-
{description && <meta name="description" content={description} />}
|
|
25
|
-
{description && (
|
|
26
|
-
<meta property="og:description" content={description} />
|
|
27
|
-
)}
|
|
28
|
-
</Head>
|
|
29
|
-
{children}
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
8
|
+
export default function Layout({ children }) {
|
|
9
|
+
return <>{children}</>;
|
|
32
10
|
}
|
|
33
|
-
|
|
34
|
-
export default Layout;
|
|
@@ -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
|
+
import type { LoadingComponentProps } from 'react-loadable';
|
|
9
|
+
export default function Loading({ error, retry, pastDelay, }: LoadingComponentProps): JSX.Element | null;
|
|
@@ -4,133 +4,67 @@
|
|
|
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
|
-
|
|
7
|
+
// Should we translate theme-fallback?
|
|
8
|
+
/* eslint-disable @docusaurus/no-untranslated-text */
|
|
8
9
|
import React from 'react';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
width: '100%',
|
|
31
|
-
}}>
|
|
32
|
-
<p>{error.message}</p>
|
|
10
|
+
export default function Loading({ error, retry, pastDelay, }) {
|
|
11
|
+
if (error) {
|
|
12
|
+
return (<div style={{
|
|
13
|
+
textAlign: 'center',
|
|
14
|
+
color: '#fff',
|
|
15
|
+
backgroundColor: '#fa383e',
|
|
16
|
+
borderColor: '#fa383e',
|
|
17
|
+
borderStyle: 'solid',
|
|
18
|
+
borderRadius: '0.25rem',
|
|
19
|
+
borderWidth: '1px',
|
|
20
|
+
boxSizing: 'border-box',
|
|
21
|
+
display: 'block',
|
|
22
|
+
padding: '1rem',
|
|
23
|
+
flex: '0 0 50%',
|
|
24
|
+
marginLeft: '25%',
|
|
25
|
+
marginRight: '25%',
|
|
26
|
+
marginTop: '5rem',
|
|
27
|
+
maxWidth: '50%',
|
|
28
|
+
width: '100%',
|
|
29
|
+
}}>
|
|
30
|
+
<p>{String(error)}</p>
|
|
33
31
|
<div>
|
|
34
32
|
<button type="button" onClick={retry}>
|
|
35
33
|
Retry
|
|
36
34
|
</button>
|
|
37
35
|
</div>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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">
|
|
36
|
+
</div>);
|
|
37
|
+
}
|
|
38
|
+
if (pastDelay) {
|
|
39
|
+
return (<div style={{
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
height: '100vh',
|
|
44
|
+
}}>
|
|
45
|
+
<svg id="loader" style={{
|
|
46
|
+
width: 128,
|
|
47
|
+
height: 110,
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
top: 'calc(100vh - 64%)',
|
|
50
|
+
}} viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#61dafb">
|
|
51
|
+
<g fill="none" fillRule="evenodd" transform="translate(1 1)" strokeWidth="2">
|
|
67
52
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
68
|
-
<animate
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
/>
|
|
53
|
+
<animate attributeName="r" begin="1.5s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
54
|
+
<animate attributeName="stroke-opacity" begin="1.5s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
55
|
+
<animate attributeName="stroke-width" begin="1.5s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
92
56
|
</circle>
|
|
93
57
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
94
|
-
<animate
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
/>
|
|
58
|
+
<animate attributeName="r" begin="3s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
59
|
+
<animate attributeName="stroke-opacity" begin="3s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
60
|
+
<animate attributeName="stroke-width" begin="3s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
118
61
|
</circle>
|
|
119
62
|
<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
|
-
/>
|
|
63
|
+
<animate attributeName="r" begin="0s" dur="1.5s" values="6;1;2;3;4;5;6" calcMode="linear" repeatCount="indefinite"/>
|
|
128
64
|
</circle>
|
|
129
65
|
</g>
|
|
130
66
|
</svg>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return null;
|
|
136
|
-
};
|
|
67
|
+
</div>);
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
@@ -4,4 +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
|
-
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
export default function NotFound(): JSX.Element;
|
|
@@ -4,25 +4,26 @@
|
|
|
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
|
-
|
|
7
|
+
// Should we translate theme-fallback?
|
|
8
|
+
/* eslint-disable @docusaurus/no-untranslated-text */
|
|
8
9
|
import React from 'react';
|
|
10
|
+
import Head from '@docusaurus/Head';
|
|
9
11
|
import Layout from '@theme/Layout';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export default function NotFound() {
|
|
13
|
+
return (<>
|
|
14
|
+
<Head>
|
|
15
|
+
<title>Page Not Found</title>
|
|
16
|
+
</Head>
|
|
17
|
+
<Layout>
|
|
18
|
+
<div style={{
|
|
19
|
+
display: 'flex',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
height: '50vh',
|
|
23
|
+
fontSize: '20px',
|
|
21
24
|
}}>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
<h1>Oops, page not found </h1>
|
|
26
|
+
</div>
|
|
27
|
+
</Layout>
|
|
28
|
+
</>);
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
export default NotFound;
|
|
@@ -0,0 +1,10 @@
|
|
|
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="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Root';
|
|
10
|
+
export default function Root({ children }: Props): JSX.Element;
|