@docusaurus/types 0.0.0-5868 → 0.0.0-5872

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "0.0.0-5868",
3
+ "version": "0.0.0-5872",
4
4
  "description": "Common types for Docusaurus packages.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -27,5 +27,5 @@
27
27
  "react": "^18.0.0",
28
28
  "react-dom": "^18.0.0"
29
29
  },
30
- "gitHead": "82bedf4154c3c66e27563a6735763c5b08518820"
30
+ "gitHead": "b059cfb578e4a80cdd8b5cf9a3c8978fb41693e3"
31
31
  }
package/src/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export {
45
45
 
46
46
  export {
47
47
  Plugin,
48
+ PluginIdentifier,
48
49
  InitializedPlugin,
49
50
  LoadedPlugin,
50
51
  PluginModule,
@@ -69,6 +70,7 @@ export {
69
70
 
70
71
  export {
71
72
  RouteConfig,
73
+ RouteMetadata,
72
74
  RouteContext,
73
75
  PluginRouteContext,
74
76
  Registry,
package/src/plugin.d.ts CHANGED
@@ -183,6 +183,8 @@ export type InitializedPlugin = Plugin & {
183
183
 
184
184
  export type LoadedPlugin = InitializedPlugin & {
185
185
  readonly content: unknown;
186
+ readonly globalData: unknown;
187
+ readonly routes: RouteConfig[];
186
188
  };
187
189
 
188
190
  export type PluginModule<Content = unknown> = {
package/src/routing.d.ts CHANGED
@@ -11,7 +11,7 @@ import type {ParsedUrlQueryInput} from 'querystring';
11
11
  * A "module" represents a unit of serialized data emitted from the plugin. It
12
12
  * will be imported on client-side and passed as props, context, etc.
13
13
  *
14
- * If it's a string, it's a file path that Webpack can `require`; if it's
14
+ * If it's a string, it's a file path that the bundler can `require`; if it's
15
15
  * an object, it can also contain `query` or other metadata.
16
16
  */
17
17
  export type Module =
@@ -36,14 +36,45 @@ export type RouteModules = {
36
36
  [propName: string]: Module | RouteModules | RouteModules[];
37
37
  };
38
38
 
39
+ /**
40
+ * Plugin authors can assign extra metadata to the created routes
41
+ * It is only available on the Node.js side, and not sent to the browser
42
+ * Optional: plugin authors are encouraged but not required to provide it
43
+ *
44
+ * Some plugins might use this data to provide additional features.
45
+ * This is the case of the sitemap plugin to provide support for "lastmod".
46
+ * See also: https://github.com/facebook/docusaurus/pull/9954
47
+ */
48
+ export type RouteMetadata = {
49
+ /**
50
+ * The source code file path that led to the creation of the current route
51
+ * In official content plugins, this is usually a Markdown or React file
52
+ * This path is expected to be relative to the site directory
53
+ */
54
+ sourceFilePath?: string;
55
+ /**
56
+ * The last updated date of this route
57
+ * This is generally read from the Git history of the sourceFilePath
58
+ * but can also be provided through other means (usually front matter)
59
+ *
60
+ * This has notably been introduced for adding "lastmod" support to the
61
+ * sitemap plugin, see https://github.com/facebook/docusaurus/pull/9954
62
+ */
63
+ lastUpdatedAt?: number;
64
+ };
65
+
39
66
  /**
40
67
  * Represents a "slice" of the final route structure returned from the plugin
41
68
  * `addRoute` action.
42
69
  */
43
70
  export type RouteConfig = {
44
- /** With leading slash. Trailing slash will be normalized by config. */
71
+ /**
72
+ * With leading slash. Trailing slash will be normalized by config.
73
+ */
45
74
  path: string;
46
- /** Component used to render this route, a path that Webpack can `require`. */
75
+ /**
76
+ * Component used to render this route, a path that the bundler can `require`.
77
+ */
47
78
  component: string;
48
79
  /**
49
80
  * Props. Each entry should be `[propName]: pathToPropModule` (created with
@@ -56,18 +87,31 @@ export type RouteConfig = {
56
87
  * here will be namespaced under {@link RouteContext.data}.
57
88
  */
58
89
  context?: RouteModules;
59
- /** Nested routes config. */
90
+ /**
91
+ * Nested routes config, useful for "layout routes" having subroutes.
92
+ */
60
93
  routes?: RouteConfig[];
61
- /** React router config option: `exact` routes would not match subroutes. */
94
+ /**
95
+ * React router config option: `exact` routes would not match subroutes.
96
+ */
62
97
  exact?: boolean;
63
98
  /**
64
99
  * React router config option: `strict` routes are sensitive to the presence
65
100
  * of a trailing slash.
66
101
  */
67
102
  strict?: boolean;
68
- /** Used to sort routes. Higher-priority routes will be placed first. */
103
+ /**
104
+ * Used to sort routes.
105
+ * Higher-priority routes will be matched first.
106
+ */
69
107
  priority?: number;
70
- /** Extra props; will be copied to routes.js. */
108
+ /**
109
+ * Optional route metadata
110
+ */
111
+ metadata?: RouteMetadata;
112
+ /**
113
+ * Extra props; will be available on the client side.
114
+ */
71
115
  [propName: string]: unknown;
72
116
  };
73
117