|
1 | 1 | import type { NamedSSRLoadedRendererValue } from 'astro';
|
2 | 2 | import { AstroError } from 'astro/errors';
|
3 |
| -import { AstroJSX, jsx } from 'astro/jsx-runtime'; |
| 3 | +import { jsx } from 'astro/jsx-runtime'; |
4 | 4 | import { renderJSX } from 'astro/runtime/server/index.js';
|
5 | 5 |
|
6 | 6 | const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
|
7 | 7 |
|
8 |
| -// NOTE: In practice, MDX components are always tagged with `__astro_tag_component__`, so the right renderer |
9 |
| -// is used directly, and this check is not often used to return true. |
10 |
| -export async function check( |
11 |
| - Component: any, |
12 |
| - props: any, |
13 |
| - { default: children = null, ...slotted } = {}, |
14 |
| -) { |
15 |
| - if (typeof Component !== 'function') return false; |
16 |
| - const slots: Record<string, any> = {}; |
17 |
| - for (const [key, value] of Object.entries(slotted)) { |
18 |
| - const name = slotName(key); |
19 |
| - slots[name] = value; |
20 |
| - } |
21 |
| - try { |
22 |
| - const result = await Component({ ...props, ...slots, children }); |
23 |
| - return result[AstroJSX]; |
24 |
| - } catch (e) { |
25 |
| - throwEnhancedErrorIfMdxComponent(e as Error, Component); |
26 |
| - } |
| 8 | +// MDX components are tagged with `__astro_tag_component__` in `vite-plugin-mdx-postprocess.ts` |
| 9 | +// and tagged componenets can directly tell Astro which renderer to use in build-time, rather |
| 10 | +// than checking the components in runtime. So this function is made a no-op as any untagged |
| 11 | +// component wouldn't have belonged to MDX. |
| 12 | +export async function check() { |
27 | 13 | return false;
|
28 | 14 | }
|
29 | 15 |
|
|
0 commit comments