Skip to content

Commit

Permalink
TS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jan 17, 2025
1 parent e499f7c commit d3028cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion packages/docusaurus-types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export {
Validate,
ValidationSchema,
AllContent,
PostBuildProps,
RouteBuildMetadata,
ConfigureWebpackUtils,
PostCssOptions,
Expand Down
13 changes: 11 additions & 2 deletions packages/docusaurus-types/src/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export type RouteBuildMetadata = {
// For now the only need is our sitemap plugin to filter noindex pages
noIndex: boolean;
};
export type PostBuildProps = Props & {
export type PostBuildProps<Content> = Props & {
content: Content;

// TODO Docusaurus v4: remove old messy unserializable "head" API
Expand All @@ -141,7 +141,16 @@ export type Plugin<Content = unknown> = {
allContent: AllContent;
actions: PluginContentLoadedActions;
}) => Promise<void> | void;
postBuild?: (props: PostBuildProps) => Promise<void> | void;
postBuild?: (
props: Props & {
content: Content;
// TODO Docusaurus v4: remove old messy unserializable "head" API
// breaking change, replaced by routesBuildMetadata
// Reason: https://github.com/facebook/docusaurus/pull/10826
head: {[location: string]: HelmetServerState};
routesBuildMetadata: {[location: string]: RouteBuildMetadata};
},
) => Promise<void> | void;
// TODO Docusaurus v4 ?
// refactor the configureWebpack API surface: use an object instead of
// multiple params (requires breaking change)
Expand Down
8 changes: 2 additions & 6 deletions packages/docusaurus/src/commands/build/buildLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import type {
ConfigureWebpackUtils,
LoadedPlugin,
Props,
PostBuildProps,
} from '@docusaurus/types';
import type {SiteCollectedData} from '../../common';
import {BuildCLIOptions} from './build';
Expand Down Expand Up @@ -139,15 +138,12 @@ async function executePluginsPostBuild({
if (!plugin.postBuild) {
return;
}

const postBuildProps: PostBuildProps = {
await plugin.postBuild({
...props,
head,
routesBuildMetadata,
content: plugin.content,
};

await plugin.postBuild(postBuildProps);
});
}),
);
}
Expand Down

0 comments on commit d3028cc

Please sign in to comment.