refactor: replace non-prop interface with type; allow plugin lifecycles to have sync type (#7080)

* refactor: replace non-prop interface with type; allow plugin lifecycles to have sync type

* fix
This commit is contained in:
Joshua Chen 2022-03-31 19:16:07 +08:00 committed by GitHub
parent ce2b631455
commit 24c205a835
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 145 additions and 138 deletions

View file

@ -24,13 +24,13 @@ The plugin module's default export is a constructor function with the signature
`context` is plugin-agnostic, and the same object will be passed into all plugins used for a Docusaurus website. The `context` object contains the following fields:
```ts
interface LoadContext {
type LoadContext = {
siteDir: string;
generatedFilesDir: string;
siteConfig: DocusaurusConfig;
outDir: string;
baseUrl: string;
}
};
```
### `options` {#options}

View file

@ -43,17 +43,17 @@ The data that was loaded in `loadContent` will be consumed in `contentLoaded`. I
Create a route to add to the website.
```ts
interface RouteConfig {
type RouteConfig = {
path: string;
component: string;
modules?: RouteModules;
routes?: RouteConfig[];
exact?: boolean;
priority?: number;
}
interface RouteModules {
};
type RouteModules = {
[module: string]: Module | RouteModules | RouteModules[];
}
};
type Module =
| {
path: string;
@ -339,7 +339,7 @@ function injectHtmlTags(): {
type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
interface HtmlTagObject {
type HtmlTagObject = {
/**
* Attributes of the HTML tag
* E.g. `{'disabled': true, 'value': 'demo', 'rel': 'preconnect'}`
@ -355,7 +355,7 @@ interface HtmlTagObject {
* The inner HTML
*/
innerHTML?: string;
}
};
```
Example: