@docusaurus/types 3.1.1 → 3.2.1
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 +2 -2
- package/src/context.d.ts +1 -0
- package/src/index.d.ts +2 -0
- package/src/plugin.d.ts +23 -7
- package/src/routing.d.ts +52 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
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": "
|
|
30
|
+
"gitHead": "f268e15264e208e6faf26117258162e988b53773"
|
|
31
31
|
}
|
package/src/context.d.ts
CHANGED
package/src/index.d.ts
CHANGED
package/src/plugin.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {TranslationFile} from './i18n';
|
|
8
|
+
import type {CodeTranslations, TranslationFile} from './i18n';
|
|
9
9
|
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
|
|
10
10
|
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
|
|
11
11
|
import type {CommanderStatic} from 'commander';
|
|
@@ -18,11 +18,11 @@ import type {RouteConfig} from './routing';
|
|
|
18
18
|
|
|
19
19
|
export type PluginOptions = {id?: string} & {[key: string]: unknown};
|
|
20
20
|
|
|
21
|
-
export type PluginConfig =
|
|
21
|
+
export type PluginConfig<Content = unknown> =
|
|
22
22
|
| string
|
|
23
23
|
| [string, PluginOptions]
|
|
24
|
-
| [PluginModule
|
|
25
|
-
| PluginModule
|
|
24
|
+
| [PluginModule<Content>, PluginOptions]
|
|
25
|
+
| PluginModule<Content>
|
|
26
26
|
| false
|
|
27
27
|
| null;
|
|
28
28
|
|
|
@@ -110,7 +110,9 @@ export type Plugin<Content = unknown> = {
|
|
|
110
110
|
contentLoaded?: (args: {
|
|
111
111
|
/** The content loaded by this plugin instance */
|
|
112
112
|
content: Content; //
|
|
113
|
-
|
|
113
|
+
actions: PluginContentLoadedActions;
|
|
114
|
+
}) => Promise<void> | void;
|
|
115
|
+
allContentLoaded?: (args: {
|
|
114
116
|
allContent: AllContent;
|
|
115
117
|
actions: PluginContentLoadedActions;
|
|
116
118
|
}) => Promise<void> | void;
|
|
@@ -163,6 +165,15 @@ export type Plugin<Content = unknown> = {
|
|
|
163
165
|
}) => ThemeConfig;
|
|
164
166
|
};
|
|
165
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Data required to uniquely identify a plugin
|
|
170
|
+
* The name or instance id alone is not enough
|
|
171
|
+
*/
|
|
172
|
+
export type PluginIdentifier = {
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly id: string;
|
|
175
|
+
};
|
|
176
|
+
|
|
166
177
|
export type InitializedPlugin = Plugin & {
|
|
167
178
|
readonly options: Required<PluginOptions>;
|
|
168
179
|
readonly version: PluginVersionInformation;
|
|
@@ -172,10 +183,15 @@ export type InitializedPlugin = Plugin & {
|
|
|
172
183
|
|
|
173
184
|
export type LoadedPlugin = InitializedPlugin & {
|
|
174
185
|
readonly content: unknown;
|
|
186
|
+
readonly globalData: unknown;
|
|
187
|
+
readonly routes: RouteConfig[];
|
|
188
|
+
readonly defaultCodeTranslations: CodeTranslations;
|
|
175
189
|
};
|
|
176
190
|
|
|
177
|
-
export type PluginModule = {
|
|
178
|
-
(context: LoadContext, options: unknown):
|
|
191
|
+
export type PluginModule<Content = unknown> = {
|
|
192
|
+
(context: LoadContext, options: unknown):
|
|
193
|
+
| Plugin<Content>
|
|
194
|
+
| Promise<Plugin<Content>>;
|
|
179
195
|
validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
|
|
180
196
|
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
|
|
181
197
|
|
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
|
|
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
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* With leading slash. Trailing slash will be normalized by config.
|
|
73
|
+
*/
|
|
45
74
|
path: string;
|
|
46
|
-
/**
|
|
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
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Nested routes config, useful for "layout routes" having subroutes.
|
|
92
|
+
*/
|
|
60
93
|
routes?: RouteConfig[];
|
|
61
|
-
/**
|
|
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
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Used to sort routes.
|
|
105
|
+
* Higher-priority routes will be matched first.
|
|
106
|
+
*/
|
|
69
107
|
priority?: number;
|
|
70
|
-
/**
|
|
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
|
|
|
@@ -75,7 +119,7 @@ export type RouteContext = {
|
|
|
75
119
|
/**
|
|
76
120
|
* Plugin-specific context data.
|
|
77
121
|
*/
|
|
78
|
-
data?:
|
|
122
|
+
data?: {[key: string]: unknown};
|
|
79
123
|
};
|
|
80
124
|
|
|
81
125
|
/**
|