mdxlayer
Version:
Transform your MDX content into typed, JSON-powered data with flexible schema validation.
20 lines (17 loc) • 471 B
JavaScript
import { compile } from '@mdx-js/mdx';
const processMDX = async (options = {}, raw) => {
try {
const compiled = await compile(raw, {
format: "mdx",
...options,
outputFormat: "function-body",
rehypePlugins: options.rehypePlugins ?? [],
remarkPlugins: options.remarkPlugins ?? []
});
return String(compiled.value);
} catch (err) {
console.error("Error processing MDX:", err);
return "";
}
};
export { processMDX };