import type { NodeComponentProps } from 'markstream-react' import MarkdownRender, { MarkdownCodeBlockNode, setCustomComponents } from 'markstream-react' import 'markstream-react/index.css' function rewriteDocsUrl(url: string) { if (url.startsWith('/docs/')) return `https://markstream.example.com${url}` return url } function CustomHeading({ node, ctx, renderNode, indexKey }: NodeComponentProps) { const Tag = `h${node.level || 1}` as keyof JSX.IntrinsicElements return ( {node.children?.map((child: any, i: number) => renderNode && ctx ? renderNode(child, `${String(indexKey)}-heading-${i}`, ctx) : null, )} ) } function CustomLink({ node, ctx, renderNode, indexKey }: NodeComponentProps) { const href = rewriteDocsUrl(node.href) return ( {node.children?.map((child: any, i: number) => renderNode && ctx ? renderNode(child, `${String(indexKey)}-link-${i}`, ctx) : null, )} ) } setCustomComponents('migration-demo', { heading: CustomHeading, link: CustomLink, code_block: ({ node, isDark, ctx }: any) => ( ), }) export function AdvancedArticle({ markdown }: { markdown: string }) { return ( ) } // If the previous component depended on `allowedElements`, filter the parsed // node tree before render. There is no direct allowlist prop on markstream-react.