Skip to content

Commit bcd2948

Browse files
committed
Revert "[code-infra] Drop layoutConfig threading from API page generator"
This reverts commit 2c4ad79.
1 parent 2c4ad79 commit bcd2948

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

packages-internal/api-docs-builder/src/ApiBuilders/ComponentApiBuilder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ const generateApiPage = async (
310310
reactApi: ComponentReactApi,
311311
sortingStrategies?: SortingStrategiesType,
312312
onlyJsonFile: boolean = false,
313+
layoutConfigPath: string = '',
313314
) => {
314315
const normalizedApiPathname = reactApi.apiPathname.replace(/\\/g, '/');
315316
/**
@@ -377,13 +378,18 @@ const generateApiPage = async (
377378
path.resolve(apiPagesDirectory, `${kebabCase(reactApi.name)}.js`),
378379
`import * as React from 'react';
379380
import { ApiPage } from '@mui/internal-core-docs/ApiPage';
380-
import { mapApiPageTranslation } from '@mui/internal-core-docs/mapApiPageTranslations';
381+
import { mapApiPageTranslation } from '@mui/internal-core-docs/mapApiPageTranslations';${
382+
layoutConfigPath === ''
383+
? ''
384+
: `
385+
import layoutConfig from '${layoutConfigPath}';`
386+
}
381387
import translation from '${importTranslationPagesDirectory}/${kebabCase(reactApi.name)}/${kebabCase(reactApi.name)}.json';
382388
import jsonPageContent from './${kebabCase(reactApi.name)}.json';
383389
384390
export default function Page(props) {
385391
const { descriptions } = props;
386-
return <ApiPage descriptions={descriptions} pageContent={jsonPageContent} />;
392+
return <ApiPage ${layoutConfigPath === '' ? '' : '{...layoutConfig} '}descriptions={descriptions} pageContent={jsonPageContent} />;
387393
}
388394
389395
export async function getStaticProps() {
@@ -913,6 +919,7 @@ export default async function generateComponentApi(
913919
reactApi,
914920
projectSettings.sortingStrategies,
915921
generateJsonFileOnly,
922+
componentInfo.layoutConfigPath,
916923
);
917924

918925
if (

packages-internal/api-docs-builder/src/types/utils.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export type ComponentInfo = {
4949
};
5050
getDemos: () => Array<{ demoPageTitle: string; demoPathname: string; filePath: string }>;
5151
apiPagesDirectory: string;
52+
/**
53+
* The path to import specific layout config of the page if needed.
54+
*/
55+
layoutConfigPath?: string;
5256
skipApiGeneration?: boolean;
5357
/**
5458
* If `true`, the component's name match one of the MUI System components.

0 commit comments

Comments
 (0)