@docusaurus/core 2.0.0-beta.2 → 2.0.0-beta.22
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.mjs +221 -0
- 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/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 +40 -40
- 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/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- 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/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- 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 +104 -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 +101 -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 +118 -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 -134
- 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 +22 -9
- 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/docusaurus.js +0 -325
- 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 -8
- 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
|
@@ -6,72 +6,105 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Loadable from 'react-loadable';
|
|
9
|
-
import Loading from '@theme/Loading';
|
|
10
9
|
import routesChunkNames from '@generated/routesChunkNames';
|
|
11
10
|
import registry from '@generated/registry';
|
|
11
|
+
import Loading from '@theme/Loading';
|
|
12
12
|
import flat from '../flat';
|
|
13
|
-
|
|
13
|
+
import { RouteContextProvider } from '../routeContext';
|
|
14
|
+
export default function ComponentCreator(path, hash) {
|
|
14
15
|
// 404 page
|
|
15
16
|
if (path === '*') {
|
|
16
17
|
return Loadable({
|
|
17
18
|
loading: Loading,
|
|
18
19
|
loader: () => import('@theme/NotFound'),
|
|
20
|
+
modules: ['@theme/NotFound'],
|
|
21
|
+
webpack: () => [require.resolveWeak('@theme/NotFound')],
|
|
22
|
+
render(loaded, props) {
|
|
23
|
+
const NotFound = loaded.default;
|
|
24
|
+
return (<RouteContextProvider
|
|
25
|
+
// Do we want a better name than native-default?
|
|
26
|
+
value={{ plugin: { name: 'native', id: 'default' } }}>
|
|
27
|
+
<NotFound {...props}/>
|
|
28
|
+
</RouteContextProvider>);
|
|
29
|
+
},
|
|
19
30
|
});
|
|
20
31
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
32
|
+
const chunkNames = routesChunkNames[`${path}-${hash}`];
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
const loader = {};
|
|
35
|
+
const modules = [];
|
|
24
36
|
const optsWebpack = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
component: () => import('./Pages.js'),
|
|
32
|
-
content.foo: () => import('./doc1.md'),
|
|
33
|
-
}
|
|
34
|
-
- optsModules: ['./Pages.js', './doc1.md']
|
|
35
|
-
- optsWebpack: [require.resolveWeak('./Pages.js'), require.resolveWeak('./doc1.md')]
|
|
36
|
-
*/
|
|
37
|
+
// A map from prop names to chunk names.
|
|
38
|
+
// e.g. Suppose the plugin added this as route:
|
|
39
|
+
// { __comp: "...", prop: { foo: "..." }, items: ["...", "..."] }
|
|
40
|
+
// It will become:
|
|
41
|
+
// { __comp: "...", "prop.foo": "...", "items.0": "...", "items.1": ... }
|
|
42
|
+
// Loadable.Map will _map_ over `loader` and load each key.
|
|
37
43
|
const flatChunkNames = flat(chunkNames);
|
|
38
|
-
Object.
|
|
39
|
-
const chunkRegistry = registry[
|
|
44
|
+
Object.entries(flatChunkNames).forEach(([keyPath, chunkName]) => {
|
|
45
|
+
const chunkRegistry = registry[chunkName];
|
|
40
46
|
if (chunkRegistry) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
// eslint-disable-next-line prefer-destructuring
|
|
48
|
+
loader[keyPath] = chunkRegistry[0];
|
|
49
|
+
modules.push(chunkRegistry[1]);
|
|
44
50
|
optsWebpack.push(chunkRegistry[2]);
|
|
45
|
-
/* eslint-enable prefer-destructuring */
|
|
46
51
|
}
|
|
47
52
|
});
|
|
48
53
|
return Loadable.Map({
|
|
49
54
|
loading: Loading,
|
|
50
|
-
loader
|
|
51
|
-
modules
|
|
55
|
+
loader,
|
|
56
|
+
modules,
|
|
52
57
|
webpack: () => optsWebpack,
|
|
53
|
-
render
|
|
54
|
-
//
|
|
58
|
+
render(loaded, props) {
|
|
59
|
+
// `loaded` will be a map from key path (as returned from the flattened
|
|
60
|
+
// chunk names) to the modules loaded from the loaders. We now have to
|
|
61
|
+
// restore the chunk names' previous shape from this flat record.
|
|
62
|
+
// We do so by taking advantage of the existing `chunkNames` and replacing
|
|
63
|
+
// each chunk name with its loaded module, so we don't create another
|
|
64
|
+
// object from scratch.
|
|
55
65
|
const loadedModules = JSON.parse(JSON.stringify(chunkNames));
|
|
56
|
-
Object.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
Object.entries(loaded).forEach(([keyPath, loadedModule]) => {
|
|
67
|
+
// JSON modules are also loaded as `{ default: ... }` (`import()`
|
|
68
|
+
// semantics) but we just want to pass the actual value to props.
|
|
69
|
+
const chunk = loadedModule.default;
|
|
70
|
+
// One loaded chunk can only be one of two things: a module (props) or a
|
|
71
|
+
// component. Modules are always JSON, so `default` always exists. This
|
|
72
|
+
// could only happen with a user-defined component.
|
|
73
|
+
if (!chunk) {
|
|
74
|
+
throw new Error(`The page component at ${path} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);
|
|
61
75
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
// A module can be a primitive, for example, if the user stored a string
|
|
77
|
+
// as a prop. However, there seems to be a bug with swc-loader's CJS
|
|
78
|
+
// logic, in that it would load a JSON module with content "foo" as
|
|
79
|
+
// `{ default: "foo", 0: "f", 1: "o", 2: "o" }`. Just to be safe, we
|
|
80
|
+
// first make sure that the chunk is non-primitive.
|
|
81
|
+
if (typeof chunk === 'object' || typeof chunk === 'function') {
|
|
82
|
+
Object.keys(loadedModule)
|
|
83
|
+
.filter((k) => k !== 'default')
|
|
84
|
+
.forEach((nonDefaultKey) => {
|
|
85
|
+
chunk[nonDefaultKey] =
|
|
86
|
+
loadedModule[nonDefaultKey];
|
|
68
87
|
});
|
|
69
88
|
}
|
|
89
|
+
// We now have this chunk prepared. Go down the key path and replace the
|
|
90
|
+
// chunk name with the actual chunk.
|
|
91
|
+
let val = loadedModules;
|
|
92
|
+
const keyPaths = keyPath.split('.');
|
|
93
|
+
keyPaths.slice(0, -1).forEach((k) => {
|
|
94
|
+
val = val[k];
|
|
95
|
+
});
|
|
96
|
+
val[keyPaths[keyPaths.length - 1]] = chunk;
|
|
70
97
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
/* eslint-disable no-underscore-dangle */
|
|
99
|
+
const Component = loadedModules.__comp;
|
|
100
|
+
delete loadedModules.__comp;
|
|
101
|
+
const routeContext = loadedModules.__context;
|
|
102
|
+
delete loadedModules.__context;
|
|
103
|
+
/* eslint-enable no-underscore-dangle */
|
|
104
|
+
// Is there any way to put this RouteContextProvider upper in the tree?
|
|
105
|
+
return (<RouteContextProvider value={routeContext}>
|
|
106
|
+
<Component {...loadedModules} {...props}/>
|
|
107
|
+
</RouteContextProvider>);
|
|
74
108
|
},
|
|
75
109
|
});
|
|
76
110
|
}
|
|
77
|
-
export default ComponentCreator;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
import React, { type ReactNode } from 'react';
|
|
9
|
+
import type { Props } from '@docusaurus/ErrorBoundary';
|
|
10
|
+
declare type State = {
|
|
11
|
+
error: Error | null;
|
|
12
|
+
};
|
|
13
|
+
export default class ErrorBoundary extends React.Component<Props, State> {
|
|
14
|
+
constructor(props: Props);
|
|
15
|
+
componentDidCatch(error: Error): void;
|
|
16
|
+
render(): ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
9
|
+
import ThemeError from '@theme/Error';
|
|
10
|
+
// eslint-disable-next-line react/function-component-definition
|
|
11
|
+
const DefaultFallback = (params) => (<ThemeError {...params}/>);
|
|
12
|
+
export default class ErrorBoundary extends React.Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
this.state = { error: null };
|
|
16
|
+
}
|
|
17
|
+
componentDidCatch(error) {
|
|
18
|
+
// Catch errors in any components below and re-render with error message
|
|
19
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
20
|
+
this.setState({ error });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
const { children } = this.props;
|
|
25
|
+
const { error } = this.state;
|
|
26
|
+
if (error) {
|
|
27
|
+
const fallbackParams = {
|
|
28
|
+
error,
|
|
29
|
+
tryAgain: () => this.setState({ error: null }),
|
|
30
|
+
};
|
|
31
|
+
const fallback = this.props.fallback ?? DefaultFallback;
|
|
32
|
+
return fallback(fallbackParams);
|
|
33
|
+
}
|
|
34
|
+
// See https://github.com/facebook/docusaurus/issues/6337#issuecomment-1012913647
|
|
35
|
+
return children ?? null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -6,6 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
8
|
/// <reference types="react" />
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
export default Head;
|
|
9
|
+
import type { Props } from '@docusaurus/Head';
|
|
10
|
+
export default function Head(props: Props): JSX.Element;
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import { Helmet } from 'react-helmet';
|
|
9
|
-
function Head(props) {
|
|
10
|
-
return
|
|
8
|
+
import { Helmet } from 'react-helmet-async';
|
|
9
|
+
export default function Head(props) {
|
|
10
|
+
return <Helmet {...props}/>;
|
|
11
11
|
}
|
|
12
|
-
export default Head;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
import { ReactNode } from 'react';
|
|
8
|
+
import { type ReactNode } from 'react';
|
|
9
9
|
import type { InterpolateProps, InterpolateValues } from '@docusaurus/Interpolate';
|
|
10
10
|
export declare function interpolate<Str extends string>(text: Str, values?: InterpolateValues<Str, string | number>): string;
|
|
11
11
|
export declare function interpolate<Str extends string, Value extends ReactNode>(text: Str, values?: InterpolateValues<Str, Value>): ReactNode;
|
|
12
|
-
export default function Interpolate<Str extends string>({ children, values, }: InterpolateProps<Str>):
|
|
12
|
+
export default function Interpolate<Str extends string>({ children, values, }: InterpolateProps<Str>): JSX.Element;
|
|
@@ -4,59 +4,30 @@
|
|
|
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 React from 'react';
|
|
8
|
-
/*
|
|
9
|
-
Minimal implementation of a React interpolate component.
|
|
10
|
-
We don't ship a markdown parser nor a feature-complete i18n library on purpose.
|
|
11
|
-
More details here: https://github.com/facebook/docusaurus/pull/4295
|
|
12
|
-
*/
|
|
13
|
-
const ValueRegexp = /{\w+}/g;
|
|
14
|
-
const ValueFoundMarker = '{}'; // does not care much
|
|
7
|
+
import React, { isValidElement } from 'react';
|
|
15
8
|
export function interpolate(text, values) {
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
String(value);
|
|
26
|
-
elements.push(element);
|
|
27
|
-
return ValueFoundMarker;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return match; // no match? add warning?
|
|
9
|
+
// eslint-disable-next-line prefer-named-capture-group
|
|
10
|
+
const segments = text.split(/(\{\w+\})/).map((seg, index) => {
|
|
11
|
+
// Odd indices (1, 3, 5...) of the segments are (potentially) interpolatable
|
|
12
|
+
if (index % 2 === 1) {
|
|
13
|
+
const value = values?.[seg.slice(1, -1)];
|
|
14
|
+
if (value !== undefined) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
// No match: add warning? There's no way to "escape" interpolation though
|
|
31
18
|
}
|
|
19
|
+
return seg;
|
|
32
20
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Basic string interpolation: returns interpolated string
|
|
38
|
-
else if (elements.every((el) => typeof el === 'string')) {
|
|
39
|
-
return processedText
|
|
40
|
-
.split(ValueFoundMarker)
|
|
41
|
-
.reduce((str, value, index) => {
|
|
42
|
-
var _a;
|
|
43
|
-
return str.concat(value).concat((_a = elements[index]) !== null && _a !== void 0 ? _a : '');
|
|
44
|
-
}, '');
|
|
45
|
-
}
|
|
46
|
-
// JSX interpolation: returns ReactNode
|
|
47
|
-
else {
|
|
48
|
-
return processedText
|
|
49
|
-
.split(ValueFoundMarker)
|
|
50
|
-
.reduce((array, value, index) => {
|
|
51
|
-
return [
|
|
52
|
-
...array,
|
|
53
|
-
React.createElement(React.Fragment, { key: index },
|
|
54
|
-
value,
|
|
55
|
-
elements[index]),
|
|
56
|
-
];
|
|
57
|
-
}, []);
|
|
21
|
+
if (segments.some((seg) => isValidElement(seg))) {
|
|
22
|
+
return segments
|
|
23
|
+
.map((seg, index) => isValidElement(seg) ? React.cloneElement(seg, { key: index }) : seg)
|
|
24
|
+
.filter((seg) => seg !== '');
|
|
58
25
|
}
|
|
26
|
+
return segments.join('');
|
|
59
27
|
}
|
|
60
28
|
export default function Interpolate({ children, values, }) {
|
|
61
|
-
|
|
29
|
+
if (typeof children !== 'string') {
|
|
30
|
+
throw new Error(`The Docusaurus <Interpolate> component only accept simple string values. Received: ${isValidElement(children) ? 'React element' : typeof children}`);
|
|
31
|
+
}
|
|
32
|
+
return <>{interpolate(children, values)}</>;
|
|
62
33
|
}
|
|
@@ -5,13 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
interface Window {
|
|
13
|
-
docusaurus: typeof docusaurus;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
declare function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLinkCheck': noBrokenLinkCheck, autoAddBaseUrl, ...props }: LinkProps): JSX.Element;
|
|
17
|
-
export default Link;
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import type { Props } from '@docusaurus/Link';
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "location" | "children" | "replace" | "slot" | "style" | "title" | "component" | "exact" | "sensitive" | "strict" | "type" | "key" | "id" | "lang" | "dir" | "property" | "rel" | "href" | "isNavLink" | "className" | "to" | "innerRef" | "download" | "hrefLang" | "media" | "ping" | "target" | "referrerPolicy" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "activeClassName" | "activeStyle" | "isActive" | "data-noBrokenLinkCheck" | "autoAddBaseUrl"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
11
|
+
export default _default;
|
|
@@ -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
|
-
import React, { useEffect, useRef } from 'react';
|
|
7
|
+
import React, { useEffect, useImperativeHandle, useRef, } from 'react';
|
|
8
8
|
import { NavLink, Link as RRLink } from 'react-router-dom';
|
|
9
|
+
import { applyTrailingSlash } from '@docusaurus/utils-common';
|
|
9
10
|
import useDocusaurusContext from './useDocusaurusContext';
|
|
10
11
|
import isInternalUrl from './isInternalUrl';
|
|
11
12
|
import ExecutionEnvironment from './ExecutionEnvironment';
|
|
12
13
|
import { useLinksCollector } from '../LinksCollector';
|
|
13
14
|
import { useBaseUrlUtils } from './useBaseUrl';
|
|
14
|
-
import { applyTrailingSlash } from '@docusaurus/utils-common';
|
|
15
15
|
// TODO all this wouldn't be necessary if we used ReactRouter basename feature
|
|
16
16
|
// We don't automatically add base urls to all links,
|
|
17
17
|
// only the "safe" ones, starting with / (like /docs/introduction)
|
|
18
18
|
// this is because useBaseUrl() actually transforms relative links
|
|
19
19
|
// like "introduction" to "/baseUrl/introduction" => bad behavior to fix
|
|
20
20
|
const shouldAddBaseUrlAutomatically = (to) => to.startsWith('/');
|
|
21
|
-
function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLinkCheck': noBrokenLinkCheck, autoAddBaseUrl = true, ...props }) {
|
|
22
|
-
|
|
23
|
-
const { siteConfig: { trailingSlash }, } = useDocusaurusContext();
|
|
21
|
+
function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLinkCheck': noBrokenLinkCheck, autoAddBaseUrl = true, ...props }, forwardedRef) {
|
|
22
|
+
const { siteConfig: { trailingSlash, baseUrl }, } = useDocusaurusContext();
|
|
24
23
|
const { withBaseUrl } = useBaseUrlUtils();
|
|
25
24
|
const linksCollector = useLinksCollector();
|
|
25
|
+
const innerRef = useRef(null);
|
|
26
|
+
useImperativeHandle(forwardedRef, () => innerRef.current);
|
|
26
27
|
// IMPORTANT: using to or href should not change anything
|
|
27
28
|
// For example, MDX links will ALWAYS give us the href props
|
|
28
29
|
// Using one prop or the other should not be used to distinguish
|
|
@@ -40,44 +41,40 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
40
41
|
// see https://github.com/facebook/docusaurus/issues/3309
|
|
41
42
|
// note: we want baseUrl to be appended (see issue for details)
|
|
42
43
|
// TODO read routes and automatically detect internal/external links?
|
|
43
|
-
const targetLinkWithoutPathnameProtocol = targetLinkUnprefixed
|
|
44
|
+
const targetLinkWithoutPathnameProtocol = targetLinkUnprefixed?.replace('pathname://', '');
|
|
44
45
|
// TODO we should use ReactRouter basename feature instead!
|
|
45
46
|
// Automatically apply base url in links that start with /
|
|
46
47
|
let targetLink = typeof targetLinkWithoutPathnameProtocol !== 'undefined'
|
|
47
48
|
? maybeAddBaseUrl(targetLinkWithoutPathnameProtocol)
|
|
48
49
|
: undefined;
|
|
49
50
|
if (targetLink && isInternal) {
|
|
50
|
-
targetLink = applyTrailingSlash(targetLink, trailingSlash);
|
|
51
|
+
targetLink = applyTrailingSlash(targetLink, { trailingSlash, baseUrl });
|
|
51
52
|
}
|
|
52
53
|
const preloaded = useRef(false);
|
|
53
|
-
const LinkComponent = isNavLink ? NavLink : RRLink;
|
|
54
|
+
const LinkComponent = (isNavLink ? NavLink : RRLink);
|
|
54
55
|
const IOSupported = ExecutionEnvironment.canUseIntersectionObserver;
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
const ioRef = useRef();
|
|
57
|
+
const handleRef = (el) => {
|
|
58
|
+
innerRef.current = el;
|
|
59
|
+
if (IOSupported && el && isInternal) {
|
|
60
|
+
// If IO supported and element reference found, set up Observer.
|
|
61
|
+
ioRef.current = new window.IntersectionObserver((entries) => {
|
|
62
|
+
entries.forEach((entry) => {
|
|
63
|
+
if (el === entry.target) {
|
|
64
|
+
// If element is in viewport, stop observing and run callback.
|
|
65
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
|
|
66
|
+
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
|
67
|
+
ioRef.current.unobserve(el);
|
|
68
|
+
ioRef.current.disconnect();
|
|
69
|
+
if (targetLink != null) {
|
|
70
|
+
window.docusaurus.prefetch(targetLink);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
// Add element to the observer.
|
|
71
|
-
io.observe(el);
|
|
72
|
-
};
|
|
73
|
-
const handleRef = (ref) => {
|
|
74
|
-
if (IOSupported && ref && isInternal) {
|
|
75
|
-
// If IO supported and element reference found, setup Observer functionality.
|
|
76
|
-
handleIntersection(ref, () => {
|
|
77
|
-
if (targetLink != null) {
|
|
78
|
-
window.docusaurus.prefetch(targetLink);
|
|
79
|
-
}
|
|
74
|
+
});
|
|
80
75
|
});
|
|
76
|
+
// Add element to the observer.
|
|
77
|
+
ioRef.current.observe(el);
|
|
81
78
|
}
|
|
82
79
|
};
|
|
83
80
|
const onMouseEnter = () => {
|
|
@@ -95,19 +92,22 @@ function Link({ isNavLink, to, href, activeClassName, isActive, 'data-noBrokenLi
|
|
|
95
92
|
}
|
|
96
93
|
// When unmounting, stop intersection observer from watching.
|
|
97
94
|
return () => {
|
|
98
|
-
if (IOSupported &&
|
|
99
|
-
|
|
95
|
+
if (IOSupported && ioRef.current) {
|
|
96
|
+
ioRef.current.disconnect();
|
|
100
97
|
}
|
|
101
98
|
};
|
|
102
|
-
}, [targetLink, IOSupported, isInternal]);
|
|
103
|
-
const isAnchorLink =
|
|
99
|
+
}, [ioRef, targetLink, IOSupported, isInternal]);
|
|
100
|
+
const isAnchorLink = targetLink?.startsWith('#') ?? false;
|
|
104
101
|
const isRegularHtmlLink = !targetLink || !isInternal || isAnchorLink;
|
|
105
|
-
if (
|
|
102
|
+
if (!isRegularHtmlLink && !noBrokenLinkCheck) {
|
|
106
103
|
linksCollector.collectLink(targetLink);
|
|
107
104
|
}
|
|
108
105
|
return isRegularHtmlLink ? (
|
|
109
106
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
<a ref={innerRef} href={targetLink} {...(targetLinkUnprefixed &&
|
|
108
|
+
!isInternal && { target: '_blank', rel: 'noopener noreferrer' })} {...props}/>) : (<LinkComponent {...props} onMouseEnter={onMouseEnter} innerRef={handleRef} to={targetLink}
|
|
109
|
+
// Avoid "React does not recognize the `activeClassName` prop on a DOM
|
|
110
|
+
// element"
|
|
111
|
+
{...(isNavLink && { isActive, activeClassName })}/>);
|
|
112
112
|
}
|
|
113
|
-
export default Link;
|
|
113
|
+
export default React.forwardRef(Link);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
8
|
/// <reference types="react" />
|
|
9
|
-
import { InterpolateValues } from '@docusaurus/Interpolate';
|
|
9
|
+
import { type InterpolateValues } from '@docusaurus/Interpolate';
|
|
10
10
|
import type { TranslateParam, TranslateProps } from '@docusaurus/Translate';
|
|
11
11
|
export declare function translate<Str extends string>({ message, id }: TranslateParam<Str>, values?: InterpolateValues<Str, string | number>): string;
|
|
12
12
|
export default function Translate<Str extends string>({ children, id, values, }: TranslateProps<Str>): JSX.Element;
|
|
@@ -5,25 +5,30 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import
|
|
8
|
+
import { interpolate } from '@docusaurus/Interpolate';
|
|
9
9
|
// Can't read it from context, due to exposing imperative API
|
|
10
10
|
import codeTranslations from '@generated/codeTranslations';
|
|
11
11
|
function getLocalizedMessage({ id, message, }) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (typeof id === 'undefined' && typeof message === 'undefined') {
|
|
13
|
+
throw new Error('Docusaurus translation declarations must have at least a translation id or a default translation message');
|
|
14
|
+
}
|
|
15
|
+
return codeTranslations[(id ?? message)] ?? message ?? id;
|
|
14
16
|
}
|
|
15
17
|
// Imperative translation API is useful for some edge-cases:
|
|
16
18
|
// - translating page titles (meta)
|
|
17
19
|
// - translating string props (input placeholders, image alt, aria labels...)
|
|
18
20
|
export function translate({ message, id }, values) {
|
|
19
|
-
|
|
20
|
-
const localizedMessage = (_a = getLocalizedMessage({ message, id })) !== null && _a !== void 0 ? _a : message;
|
|
21
|
+
const localizedMessage = getLocalizedMessage({ message, id });
|
|
21
22
|
return interpolate(localizedMessage, values);
|
|
22
23
|
}
|
|
23
24
|
// Maybe we'll want to improve this component with additional features
|
|
24
|
-
// Like toggling a translation mode that adds a little translation button near
|
|
25
|
+
// Like toggling a translation mode that adds a little translation button near
|
|
26
|
+
// the text?
|
|
25
27
|
export default function Translate({ children, id, values, }) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (children && typeof children !== 'string') {
|
|
29
|
+
console.warn('Illegal <Translate> children', children);
|
|
30
|
+
throw new Error('The Docusaurus <Translate> component only accept simple string values');
|
|
31
|
+
}
|
|
32
|
+
const localizedMessage = getLocalizedMessage({ message: children, id });
|
|
33
|
+
return <>{interpolate(localizedMessage, values)}</>;
|
|
29
34
|
}
|
|
@@ -4,15 +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
|
-
|
|
8
|
-
// eslint-disable-next-line no-restricted-imports
|
|
9
|
-
export {
|
|
10
|
-
// constants were only available on node
|
|
11
|
-
// this makes some useful constants available to frontend/themes too
|
|
12
|
-
// import {DEFAULT_PLUGIN_ID} '@docusaurus/constants'
|
|
13
|
-
DEFAULT_PLUGIN_ID,
|
|
14
|
-
} from '../../constants';
|
|
15
|
-
*/
|
|
16
|
-
// Not duplicating the constants seems to produce
|
|
17
|
-
// weird TS compilation side-effects
|
|
7
|
+
// Constants used on the client-side: duplicated from server-side code
|
|
18
8
|
export const DEFAULT_PLUGIN_ID = 'default';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export function hasProtocol(url) {
|
|
8
|
-
return /^(
|
|
8
|
+
return /^(?:\w*:|\/\/)/.test(url);
|
|
9
9
|
}
|
|
10
10
|
export default function isInternalUrl(url) {
|
|
11
11
|
return typeof url !== 'undefined' && !hasProtocol(url);
|
|
@@ -4,5 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
export default renderRoutes;
|
|
7
|
+
export { renderRoutes as default } from 'react-router-config';
|
|
@@ -4,5 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
export default renderRoutes;
|
|
7
|
+
export { renderRoutes as default } from 'react-router-config';
|