Files
zeekay ca2c2f21a1 Merge upstream fumadocs dev (27 commits)
- Synced with upstream fumadocs changes
- Accepted upstream changes for all conflicts
- Deleted files that no longer exist upstream
- Maintains @hanzo package namespace
2025-12-30 17:54:34 -08:00

37 lines
913 B
TypeScript

import type { TableOfContents } from '@hanzo/docs-core/toc';
import type { MdxContent } from '@/render';
export * from './compile';
export { parseFrontmatter } from './utils';
/**
* @deprecated Use `compiler.render` instead
*/
export async function executeMdx(compiled: string, scope: object, baseUrl?: string | URL) {
let jsxRuntime;
if (process.env.NODE_ENV === 'production') {
jsxRuntime = await import('react/jsx-runtime');
} else {
jsxRuntime = await import('react/jsx-dev-runtime');
}
const fullScope = {
opts: {
...jsxRuntime,
baseUrl,
},
...scope,
};
const values = Object.values(fullScope);
const params = Object.keys(fullScope);
params.push(`return (async () => { ${compiled} })()`);
const hydrateFn = new Function(...params);
return (await hydrateFn.apply(hydrateFn, values)) as {
default: MdxContent;
toc?: TableOfContents;
};
}