@docusaurus/core 0.0.0-4836 → 0.0.0-4839
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/lib/server/plugins/index.js +6 -8
- package/lib/server/routes.js +4 -1
- package/package.json +10 -10
|
@@ -69,13 +69,11 @@ async function loadPlugins(context) {
|
|
|
69
69
|
const pluginId = plugin.options.id;
|
|
70
70
|
// plugins data files are namespaced by pluginName/pluginId
|
|
71
71
|
const dataDir = path_1.default.join(context.generatedFilesDir, plugin.name, pluginId);
|
|
72
|
-
|
|
73
|
-
// TODO handle context for nested routes
|
|
72
|
+
const pluginRouteContextModulePath = path_1.default.join(dataDir, `${(0, utils_1.docuHash)('pluginRouteContextModule')}.json`);
|
|
74
73
|
const pluginRouteContext = {
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
name: plugin.name,
|
|
75
|
+
id: pluginId,
|
|
77
76
|
};
|
|
78
|
-
const pluginRouteContextModulePath = path_1.default.join(dataDir, `${(0, utils_1.docuHash)('pluginRouteContextModule')}.json`);
|
|
79
77
|
await (0, utils_1.generate)('/', pluginRouteContextModulePath, JSON.stringify(pluginRouteContext, null, 2));
|
|
80
78
|
const actions = {
|
|
81
79
|
addRoute(initialRouteConfig) {
|
|
@@ -83,9 +81,9 @@ async function loadPlugins(context) {
|
|
|
83
81
|
const finalRouteConfig = (0, routeConfig_1.applyRouteTrailingSlash)(initialRouteConfig, context.siteConfig);
|
|
84
82
|
pluginsRouteConfigs.push({
|
|
85
83
|
...finalRouteConfig,
|
|
86
|
-
|
|
87
|
-
...finalRouteConfig.
|
|
88
|
-
|
|
84
|
+
context: {
|
|
85
|
+
...(finalRouteConfig.context && { data: finalRouteConfig.context }),
|
|
86
|
+
plugin: pluginRouteContextModulePath,
|
|
89
87
|
},
|
|
90
88
|
});
|
|
91
89
|
},
|
package/lib/server/routes.js
CHANGED
|
@@ -148,7 +148,7 @@ exports.handleDuplicateRoutes = handleDuplicateRoutes;
|
|
|
148
148
|
* `routesPaths`, and `routesChunkNames` accordingly.
|
|
149
149
|
*/
|
|
150
150
|
function genRouteCode(routeConfig, res) {
|
|
151
|
-
const { path: routePath, component, modules = {}, routes: subroutes, priority, exact, ...props } = routeConfig;
|
|
151
|
+
const { path: routePath, component, modules = {}, context, routes: subroutes, priority, exact, ...props } = routeConfig;
|
|
152
152
|
if (typeof routePath !== 'string' || !component) {
|
|
153
153
|
throw new Error(`Invalid route config: path must be a string and component is required.
|
|
154
154
|
${JSON.stringify(routeConfig)}`);
|
|
@@ -160,6 +160,9 @@ ${JSON.stringify(routeConfig)}`);
|
|
|
160
160
|
res.routesChunkNames[`${routePath}-${routeHash}`] = {
|
|
161
161
|
// Avoid clash with a prop called "component"
|
|
162
162
|
...genChunkNames({ __comp: component }, 'component', component, res),
|
|
163
|
+
...(context
|
|
164
|
+
? genChunkNames({ __context: context }, 'context', routePath, res)
|
|
165
|
+
: {}),
|
|
163
166
|
...genChunkNames(modules, 'module', routePath, res),
|
|
164
167
|
};
|
|
165
168
|
return serializeRouteConfig({
|
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-4839",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@babel/runtime": "^7.17.8",
|
|
42
42
|
"@babel/runtime-corejs3": "^7.17.8",
|
|
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-4839",
|
|
45
|
+
"@docusaurus/logger": "0.0.0-4839",
|
|
46
|
+
"@docusaurus/mdx-loader": "0.0.0-4839",
|
|
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-4839",
|
|
49
|
+
"@docusaurus/utils-common": "0.0.0-4839",
|
|
50
|
+
"@docusaurus/utils-validation": "0.0.0-4839",
|
|
51
51
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.4",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
53
|
"autoprefixer": "^10.4.4",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"webpackbar": "^5.0.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
109
|
-
"@docusaurus/types": "0.0.0-
|
|
108
|
+
"@docusaurus/module-type-aliases": "0.0.0-4839",
|
|
109
|
+
"@docusaurus/types": "0.0.0-4839",
|
|
110
110
|
"@types/detect-port": "^1.3.2",
|
|
111
111
|
"@types/nprogress": "^0.2.0",
|
|
112
112
|
"@types/react-dom": "^17.0.14",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": ">=14"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "9e77b44561516ba299e3f93d4e6d0c47c687494d"
|
|
131
131
|
}
|