diff --git a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts index a0921b4325c1ed..ebe0d2e8374a07 100644 --- a/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts @@ -360,6 +360,7 @@ const generateApiPage = async ( reactApi: ReactApi, sortingStrategies?: SortingStrategiesType, onlyJsonFile: boolean = false, + layoutConfigPath: string = '', ) => { const normalizedApiPathname = reactApi.apiPathname.replace(/\\/g, '/'); /** @@ -422,12 +423,17 @@ const generateApiPage = async ( path.resolve(apiPagesDirectory, `${kebabCase(reactApi.name)}.js`), `import * as React from 'react'; import ApiPage from 'docs/src/modules/components/ApiPage'; - import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations'; + import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';${ + layoutConfigPath === '' + ? '' + : ` + import layoutConfig from '${layoutConfigPath}';` + } import jsonPageContent from './${kebabCase(reactApi.name)}.json'; export default function Page(props) { const { descriptions, pageContent } = props; - return ; + return ; } Page.getInitialProps = () => { @@ -802,6 +808,7 @@ export default async function generateComponentApi( reactApi, projectSettings.sortingStrategies, generateJsonFileOnly, + componentInfo.layoutConfigPath, ); if ( diff --git a/packages/api-docs-builder/buildApiUtils.ts b/packages/api-docs-builder/buildApiUtils.ts index 1ef45d3484ca66..a62c632111ae4a 100644 --- a/packages/api-docs-builder/buildApiUtils.ts +++ b/packages/api-docs-builder/buildApiUtils.ts @@ -142,6 +142,10 @@ export type ComponentInfo = { }; getDemos: () => Array<{ demoPageTitle: string; demoPathname: string }>; apiPagesDirectory: string; + /** + * The path to import specific layout config of the page if needed. + */ + layoutConfigPath?: string; skipApiGeneration?: boolean; /** * If `true`, the component's name match one of the MUI System components.