mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 02:56:57 +02:00
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:
parent
ce2b631455
commit
24c205a835
38 changed files with 145 additions and 138 deletions
|
@ -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}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue