-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering <Content />
fails for MDX file containing <Fragment>
#5519
Comments
Wrote some tests for this issue at https://github.com/withastro/astro/tree/issue/5519 (failing currently, but should pass once this issue is fixed). |
Ah and here is where we fixed this previously, but I suspect only for pages not for the astro/packages/astro/src/core/render/core.ts Lines 115 to 120 in 58065cd
Compiled MDX output looks like: function _createMdxContent(props) {
const _components = Object.assign(
{
h1: 'h1',
// map of standard HTML elements used by this MDX file
},
props.components
),
{ Fragment } = _components; // <-- Look for Fragment definition in `props.components`
if (!Fragment) _missingMdxReference('Fragment', true);
// ... MDX contents as JSX ...
} So I tried modifying the MDX integration so that Content does this: export const Content = (props) => MDXContent({
...props,
components: {
Fragment,
...props.components,
},
}); This bypasses the |
What version of
astro
are you using?1.6.12
Are you using an SSR adapter? If so, which one?
n/a
What package manager are you using?
npm
What operating system are you using?
macOS / Stackblitz
Describe the Bug
(Ran into this bug as part of migrating docs to MDX and it’s a bit of blocker given how much we use
<Fragment>
to pass content to slots.)MDX supports using
<Fragment>
, which can be useful for example to pass stuff to a named slot:This renders fine for an MDX page, e.g.
src/pages/index.mdx
.If you import (or glob) the same page and use it’s
<Content />
component however:Astro will throw an error:
I guess somewhere
<Fragment>
support is being wired up when a page is rendered but that same wiring is missing for the<Content />
render.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-zq6zwz?file=src/pages/index.mdx
Participation
The text was updated successfully, but these errors were encountered: