Remove MDX Fragment hack (#5716)

* Remove MDX Fragment hack

* Update .changeset/lovely-terms-drive.md

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
This commit is contained in:
Bjorn Lu 2023-01-04 03:06:33 +08:00 committed by GitHub
parent 5eba34fcc6
commit dd56c19411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -0,0 +1,5 @@
---
'astro': major
---
Remove MDX Fragment hack. This was used by `@astrojs/mdx` to access the `Fragment` component, but isn't require anymore since `@astrojs/mdx` v0.12.1.

View file

@ -3,7 +3,7 @@ import type { LogOptions } from '../logger/core.js';
import type { RenderContext } from './context.js';
import type { Environment } from './environment.js';
import { Fragment, renderPage as runtimeRenderPage } from '../../runtime/server/index.js';
import { renderPage as runtimeRenderPage } from '../../runtime/server/index.js';
import { attachToResponse } from '../cookies/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { getParams } from '../routing/params.js';
@ -113,14 +113,6 @@ export async function renderPage(mod: ComponentInstance, ctx: RenderContext, env
Object.assign(pageProps, { components: (mod as any).components });
}
// HACK: expose `Fragment` for all MDX components
// TODO: Remove in Astro v2 — redundant as of @astrojs/mdx@>0.12.0
if (typeof mod.default === 'function' && mod.default.name.startsWith('MDX')) {
Object.assign(pageProps, {
components: Object.assign((pageProps?.components as any) ?? {}, { Fragment }),
});
}
const response = await runtimeRenderPage(
result,
Component,