@docusaurus/core 0.0.0-4738 → 0.0.0-4742
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.
|
@@ -13,7 +13,7 @@ declare type StatefulLinksCollector = LinksCollector & {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const createStatefulLinksCollector: () => StatefulLinksCollector;
|
|
15
15
|
export declare const useLinksCollector: () => LinksCollector;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function LinksCollectorProvider({ children, linksCollector, }: {
|
|
17
17
|
children: ReactNode;
|
|
18
18
|
linksCollector: LinksCollector;
|
|
19
19
|
}): JSX.Element;
|
|
@@ -22,6 +22,6 @@ const Context = React.createContext({
|
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
24
|
export const useLinksCollector = () => useContext(Context);
|
|
25
|
-
export function
|
|
25
|
+
export function LinksCollectorProvider({ children, linksCollector, }) {
|
|
26
26
|
return <Context.Provider value={linksCollector}>{children}</Context.Provider>;
|
|
27
27
|
}
|
|
@@ -51,7 +51,8 @@ export default function ComponentCreator(path, hash) {
|
|
|
51
51
|
if (chunkRegistry) {
|
|
52
52
|
// eslint-disable-next-line prefer-destructuring
|
|
53
53
|
optsLoader[key] = chunkRegistry[0];
|
|
54
|
-
optsModules.push(chunkRegistry[1]
|
|
54
|
+
optsModules.push(chunkRegistry[1]);
|
|
55
|
+
optsWebpack.push(chunkRegistry[2]);
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
return Loadable.Map({
|
|
@@ -63,19 +64,23 @@ export default function ComponentCreator(path, hash) {
|
|
|
63
64
|
// Clone the original object since we don't want to alter the original.
|
|
64
65
|
const loadedModules = JSON.parse(JSON.stringify(chunkNames));
|
|
65
66
|
Object.keys(loaded).forEach((key) => {
|
|
67
|
+
const newComp = loaded[key].default;
|
|
68
|
+
if (!newComp) {
|
|
69
|
+
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.`);
|
|
70
|
+
}
|
|
71
|
+
if (typeof newComp === 'object' || typeof newComp === 'function') {
|
|
72
|
+
Object.keys(loaded[key])
|
|
73
|
+
.filter((k) => k !== 'default')
|
|
74
|
+
.forEach((nonDefaultKey) => {
|
|
75
|
+
newComp[nonDefaultKey] = loaded[key][nonDefaultKey];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
66
78
|
let val = loadedModules;
|
|
67
79
|
const keyPath = key.split('.');
|
|
68
80
|
keyPath.slice(0, -1).forEach((k) => {
|
|
69
81
|
val = val[k];
|
|
70
82
|
});
|
|
71
|
-
val[keyPath[keyPath.length - 1]] =
|
|
72
|
-
const nonDefaultKeys = Object.keys(loaded[key]).filter((k) => k !== 'default');
|
|
73
|
-
if (nonDefaultKeys?.length) {
|
|
74
|
-
nonDefaultKeys.forEach((nonDefaultKey) => {
|
|
75
|
-
val[keyPath[keyPath.length - 1]][nonDefaultKey] =
|
|
76
|
-
loaded[key][nonDefaultKey];
|
|
77
|
-
});
|
|
78
|
-
}
|
|
83
|
+
val[keyPath[keyPath.length - 1]] = newComp;
|
|
79
84
|
});
|
|
80
85
|
const Component = loadedModules.component;
|
|
81
86
|
delete loadedModules.component;
|
|
@@ -17,7 +17,7 @@ import fs from 'fs-extra';
|
|
|
17
17
|
import routes from '@generated/routes';
|
|
18
18
|
import preload from './preload';
|
|
19
19
|
import App from './App';
|
|
20
|
-
import { createStatefulLinksCollector,
|
|
20
|
+
import { createStatefulLinksCollector, LinksCollectorProvider, } from './LinksCollector';
|
|
21
21
|
import logger from '@docusaurus/logger';
|
|
22
22
|
// eslint-disable-next-line no-restricted-imports
|
|
23
23
|
import _ from 'lodash';
|
|
@@ -57,9 +57,9 @@ async function doRender(locals) {
|
|
|
57
57
|
const appHtml = ReactDOMServer.renderToString(<Loadable.Capture report={(moduleName) => modules.add(moduleName)}>
|
|
58
58
|
<HelmetProvider context={helmetContext}>
|
|
59
59
|
<StaticRouter location={location} context={context}>
|
|
60
|
-
<
|
|
60
|
+
<LinksCollectorProvider linksCollector={linksCollector}>
|
|
61
61
|
<App />
|
|
62
|
-
</
|
|
62
|
+
</LinksCollectorProvider>
|
|
63
63
|
</StaticRouter>
|
|
64
64
|
</HelmetProvider>
|
|
65
65
|
</Loadable.Capture>);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-4742",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,26 +31,26 @@
|
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.17.
|
|
34
|
+
"@babel/core": "^7.17.8",
|
|
35
35
|
"@babel/generator": "^7.17.7",
|
|
36
36
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
37
37
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
38
38
|
"@babel/preset-env": "^7.16.11",
|
|
39
39
|
"@babel/preset-react": "^7.16.7",
|
|
40
40
|
"@babel/preset-typescript": "^7.16.7",
|
|
41
|
-
"@babel/runtime": "^7.17.
|
|
41
|
+
"@babel/runtime": "^7.17.8",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.17.7",
|
|
43
43
|
"@babel/traverse": "^7.17.3",
|
|
44
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
45
|
-
"@docusaurus/logger": "0.0.0-
|
|
46
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
44
|
+
"@docusaurus/cssnano-preset": "0.0.0-4742",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4742",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4742",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "0.0.0-
|
|
49
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
50
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
48
|
+
"@docusaurus/utils": "0.0.0-4742",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4742",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4742",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.1",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
|
-
"autoprefixer": "^10.4.
|
|
53
|
+
"autoprefixer": "^10.4.4",
|
|
54
54
|
"babel-loader": "^8.2.3",
|
|
55
55
|
"babel-plugin-dynamic-import-node": "2.3.0",
|
|
56
56
|
"boxen": "^6.2.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"lodash": "^4.17.21",
|
|
80
80
|
"mini-css-extract-plugin": "^2.6.0",
|
|
81
81
|
"nprogress": "^0.2.0",
|
|
82
|
-
"postcss": "^8.4.
|
|
82
|
+
"postcss": "^8.4.12",
|
|
83
83
|
"postcss-loader": "^6.2.1",
|
|
84
84
|
"prompts": "^2.4.2",
|
|
85
85
|
"react-dev-utils": "^12.0.0",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
110
|
-
"@docusaurus/types": "0.0.0-
|
|
109
|
+
"@docusaurus/module-type-aliases": "0.0.0-4742",
|
|
110
|
+
"@docusaurus/types": "0.0.0-4742",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/nprogress": "^0.2.0",
|
|
113
|
-
"@types/react-dom": "^17.0.
|
|
113
|
+
"@types/react-dom": "^17.0.14",
|
|
114
114
|
"@types/react-router-config": "^5.0.6",
|
|
115
115
|
"@types/rtl-detect": "^1.0.0",
|
|
116
116
|
"@types/serve-handler": "^6.1.1",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "cef59b1a67dfd8c4bd969faeb9a79ec55faaa507"
|
|
132
132
|
}
|