mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(core): add new plugin allContentLoaded lifecycle (#9931)
This commit is contained in:
parent
d02b96f7f5
commit
8d115a9e0d
7 changed files with 791 additions and 228 deletions
16
packages/docusaurus-types/src/plugin.d.ts
vendored
16
packages/docusaurus-types/src/plugin.d.ts
vendored
|
@ -18,11 +18,11 @@ import type {RouteConfig} from './routing';
|
|||
|
||||
export type PluginOptions = {id?: string} & {[key: string]: unknown};
|
||||
|
||||
export type PluginConfig =
|
||||
export type PluginConfig<Content = unknown> =
|
||||
| string
|
||||
| [string, PluginOptions]
|
||||
| [PluginModule, PluginOptions]
|
||||
| PluginModule
|
||||
| [PluginModule<Content>, PluginOptions]
|
||||
| PluginModule<Content>
|
||||
| false
|
||||
| null;
|
||||
|
||||
|
@ -110,7 +110,9 @@ export type Plugin<Content = unknown> = {
|
|||
contentLoaded?: (args: {
|
||||
/** The content loaded by this plugin instance */
|
||||
content: Content; //
|
||||
/** Content loaded by ALL the plugins */
|
||||
actions: PluginContentLoadedActions;
|
||||
}) => Promise<void> | void;
|
||||
allContentLoaded?: (args: {
|
||||
allContent: AllContent;
|
||||
actions: PluginContentLoadedActions;
|
||||
}) => Promise<void> | void;
|
||||
|
@ -183,8 +185,10 @@ export type LoadedPlugin = InitializedPlugin & {
|
|||
readonly content: unknown;
|
||||
};
|
||||
|
||||
export type PluginModule = {
|
||||
(context: LoadContext, options: unknown): Plugin | Promise<Plugin>;
|
||||
export type PluginModule<Content = unknown> = {
|
||||
(context: LoadContext, options: unknown):
|
||||
| Plugin<Content>
|
||||
| Promise<Plugin<Content>>;
|
||||
validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
|
||||
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue