mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 06:31:47 +08:00
vue3: render mdx fix ctxt component null case
This commit is contained in:
parent
e37434ce61
commit
58efc655cf
@ -217,6 +217,15 @@ function prettierFormat(source: string): string {
|
||||
plugins: [parserHTML, parserTypescript],
|
||||
});
|
||||
}
|
||||
/**
|
||||
* get slots from vue component
|
||||
* @param ctxtComponent Vue Component
|
||||
*/
|
||||
|
||||
function getComponentSlots(ctxtComponent: any): string[] {
|
||||
if (!ctxtComponent) return [];
|
||||
return ctxtComponent?.__docgenInfo?.slots?.map((slot: { name: string }) => slot.name) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* source decorator.
|
||||
@ -245,9 +254,7 @@ export const sourceDecorator = (storyFn: any, context: StoryContext<Renderer>) =
|
||||
|
||||
const renderedComponent = components.length ? components : ctxtComponent;
|
||||
|
||||
const cWrap: any = ctxtComponent;
|
||||
|
||||
const slotProps: string[] = cWrap.__docgenInfo?.slots?.map((slot: { name: string }) => slot.name);
|
||||
const slotProps: string[] = getComponentSlots(ctxtComponent);
|
||||
|
||||
const generatedTemplate = generateSource(renderedComponent, args, context?.argTypes, slotProps);
|
||||
const generatedScript = generateSetupScript(args, context?.argTypes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user