import type { Root } from 'mdast';
import { toHast } from 'mdast-util-to-hast';
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
import { resolveRecipeAssetUrl } from '@/lib/recipe-urls';
interface RecipeMarkdownProps {
content: Root;
recipe: { category: string; slug: string };
}
// Renders a parsed markdown tree, rewriting ./assets/ image paths to served URLs
export default function RecipeMarkdown({ content, recipe }: RecipeMarkdownProps) {
return toJsxRuntime(toHast(content), {
Fragment,
jsx,
jsxs,
components: {
img: ({ src, alt }) => (
),
a: ({ href, children }) => (
{children}
),
},
});
}