@@ -0,0 +1,74 @@
1+import { memo } from "react";
2+import ReactMarkdown, { type Components } from "react-markdown";
3+
4+const components: Components = {
5+ h1: ({ children }) => (
6+ <h1 className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-3xl">
7+ {children}
8+ </h1>
9+ ),
10+ h2: ({ children }) => (
11+ <h2 className="scroll-m-20 border-b pb-2 text-xl font-semibold tracking-tight first:mt-0">
12+ {children}
13+ </h2>
14+ ),
15+ h3: ({ children }) => (
16+ <h3 className="scroll-m-20 text-lg font-semibold tracking-tight">
17+ {children}
18+ </h3>
19+ ),
20+ h4: ({ children }) => (
21+ <h4 className="scroll-m-20 text-base font-semibold tracking-tight">
22+ {children}
23+ </h4>
24+ ),
25+ p: ({ children }) => (
26+ <p className="leading-7 not-first:mt-4">{children}</p>
27+ ),
28+ blockquote: ({ children }) => (
29+ <blockquote className="mt-4 border-l-2 pl-6 italic">{children}</blockquote>
30+ ),
31+ ul: ({ children }) => (
32+ <ul className="my-4 ml-6 list-disc [&>li]:mt-2">{children}</ul>
33+ ),
34+ ol: ({ children }) => (
35+ <ol className="my-4 ml-6 list-decimal [&>li]:mt-2">{children}</ol>
36+ ),
37+ code: ({ children }) => (
38+ <code className="bg-muted relative rounded px-[0.3rem] py-[0.2rem] font-mono text-sm">
39+ {children}
40+ </code>
41+ ),
42+ pre: ({ children }) => (
43+ <pre className="bg-muted mt-4 overflow-x-auto rounded-lg p-4 font-mono text-sm">
44+ {children}
45+ </pre>
46+ ),
47+ a: ({ href, children }) => (
48+ <a
49+ href={href}
50+ target="_blank"
51+ rel="noopener noreferrer"
52+ className="text-primary underline underline-offset-4 hover:no-underline"
53+ >
54+ {children}
55+ </a>
56+ ),
57+ table: ({ children }) => (
58+ <div className="my-4 w-full overflow-y-auto">
59+ <table className="w-full">{children}</table>
60+ </div>
61+ ),
62+ th: ({ children }) => (
63+ <th className="border px-4 py-2 text-left font-bold">{children}</th>
64+ ),
65+ td: ({ children }) => (
66+ <td className="border px-4 py-2">{children}</td>
67+ ),
68+};
69+
70+export const MarkdownContent = memo(function MarkdownContent({
71+ content,
72+}: { content: string }) {
73+ return <ReactMarkdown components={components}>{content}</ReactMarkdown>;
74+});