31 lines
850 B
TypeScript
31 lines
850 B
TypeScript
'use client'
|
|
|
|
import ReactMarkdown from 'react-markdown'
|
|
import remarkGfm from 'remark-gfm'
|
|
import remarkMath from 'remark-math'
|
|
import rehypeKatex from 'rehype-katex'
|
|
import 'katex/dist/katex.min.css'
|
|
|
|
interface MarkdownContentProps {
|
|
content: string
|
|
className?: string
|
|
}
|
|
|
|
export function MarkdownContent({ content, className = '' }: MarkdownContentProps) {
|
|
return (
|
|
<div className={`prose prose-sm prose-compact dark:prose-invert max-w-none break-words ${className}`}>
|
|
<ReactMarkdown
|
|
remarkPlugins={[remarkGfm, remarkMath]}
|
|
rehypePlugins={[rehypeKatex]}
|
|
components={{
|
|
a: ({ node, ...props }) => (
|
|
<a {...props} className="text-primary hover:underline" target="_blank" rel="noopener noreferrer" />
|
|
)
|
|
}}
|
|
>
|
|
{content}
|
|
</ReactMarkdown>
|
|
</div>
|
|
)
|
|
}
|