diff options
Diffstat (limited to '')
-rw-r--r-- | packages/integrations/mdx/src/index.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts index 4d64a84d7..ecf2a9a95 100644 --- a/packages/integrations/mdx/src/index.ts +++ b/packages/integrations/mdx/src/index.ts @@ -171,11 +171,14 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI code += `\nexport const file = ${JSON.stringify(fileId)};`; } if (!moduleExports.find(({ n }) => n === 'Content')) { + // If have `export const components`, pass that as props to `Content` as fallback + const hasComponents = moduleExports.find(({ n }) => n === 'components'); + // Make `Content` the default export so we can wrap `MDXContent` and pass in `Fragment` code = code.replace('export default MDXContent;', ''); code += `\nexport const Content = (props = {}) => MDXContent({ ...props, - components: { Fragment, ...props.components }, + components: { Fragment${hasComponents ? ', ...components' : ''}, ...props.components }, }); export default Content;`; } |