@docusaurus/core 0.0.0-4838 → 0.0.0-4841

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.
@@ -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
- // TODO this would be better to do all that in the codegen phase
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
- plugin: { name: plugin.name, id: pluginId },
76
- data: undefined, // TODO allow plugins to provide context data
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
- modules: {
87
- ...finalRouteConfig.modules,
88
- __context: pluginRouteContextModulePath,
84
+ context: {
85
+ ...(finalRouteConfig.context && { data: finalRouteConfig.context }),
86
+ plugin: pluginRouteContextModulePath,
89
87
  },
90
88
  });
91
89
  },
@@ -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-4838",
4
+ "version": "0.0.0-4841",
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-4838",
45
- "@docusaurus/logger": "0.0.0-4838",
46
- "@docusaurus/mdx-loader": "0.0.0-4838",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4841",
45
+ "@docusaurus/logger": "0.0.0-4841",
46
+ "@docusaurus/mdx-loader": "0.0.0-4841",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4838",
49
- "@docusaurus/utils-common": "0.0.0-4838",
50
- "@docusaurus/utils-validation": "0.0.0-4838",
48
+ "@docusaurus/utils": "0.0.0-4841",
49
+ "@docusaurus/utils-common": "0.0.0-4841",
50
+ "@docusaurus/utils-validation": "0.0.0-4841",
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-4838",
109
- "@docusaurus/types": "0.0.0-4838",
108
+ "@docusaurus/module-type-aliases": "0.0.0-4841",
109
+ "@docusaurus/types": "0.0.0-4841",
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": "e9b56f063a75e637632bdede9cc507bece7c06f1"
130
+ "gitHead": "d8b0b5fbaeeb5c2f8c380816f817bd2c7b88ff85"
131
131
  }