'use client' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' interface MarkdownRendererProps { content: string preview?: boolean } function stripHtml(content: string): string { return content.replace(/<[^>]*>/g, '') } function getPreviewContent(content: string): string { const cleaned = stripHtml(content) const firstParagraph = cleaned.trim().split(/\n\s*\n/)[0] || '' if (firstParagraph.length <= 240) return firstParagraph return `${firstParagraph.slice(0, 240)}...` } export function MarkdownRenderer({ content, preview = false }: MarkdownRendererProps) { if (!content?.trim()) return null const cleaned = stripHtml(content) const markdownContent = preview ? getPreviewContent(content) : cleaned return (

{children}

, h2: ({ children }) =>

{children}

, h3: ({ children }) =>

{children}

, p: ({ children }) =>

{children}

, ul: ({ children }) => , ol: ({ children }) =>
    {children}
, li: ({ children }) =>
  • {children}
  • , code: ({ children, className }) => { const isInline = !className if (isInline) { return {children} } return ( {children} ) }, blockquote: ({ children }) => (
    {children}
    ), a: ({ href, children }) => ( {children} ), strong: ({ children }) => {children}, em: ({ children }) => {children}, }} > {markdownContent}
    ) }