'use client' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import Image from 'next/image' import Link from 'next/link' import { CodeBlock } from './code-block' interface MarkdownRendererProps { content: string } export default function MarkdownRenderer({ content }: MarkdownRendererProps) { return ( { const text = String(children) const id = text .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') return

{children}

}, h2: ({ children }) => { const text = String(children) const id = text .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') return

{children}

}, h3: ({ children }) => { const text = String(children) const id = text .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') return

{children}

}, code: ({ inline, className, children, ...props }: any) => { const match = /language-(\w+)/.exec(className || '') if (!inline && match) { return } return {children} }, img: ({ src, alt }) => { if (!src || typeof src !== 'string') return null const isExternal = src.startsWith('http://') || src.startsWith('https://') if (isExternal) { return {alt } return (
{alt
) }, a: ({ href, children }) => { if (!href) return <>{children} const isExternal = href.startsWith('http://') || href.startsWith('https://') if (isExternal) { return ( {children} ) } return {children} }, }} > {content}
) }