Skip to content

Commit

Permalink
Remove MDX Fragment hack (#5716)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
bluwy and delucis authored Jan 3, 2023
1 parent 5eba34f commit dd56c19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-terms-drive.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 1 addition & 9 deletions packages/astro/src/core/render/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit dd56c19

Please sign in to comment.