@@ -2,7 +2,6 @@ import remarkGfm from "remark-gfm";
2
2
import ReactMarkdown from "react-markdown" ;
3
3
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" ;
4
4
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism" ;
5
- import { cn } from "@/lib/utils" ;
6
5
import { CopyToClipboard } from "./CopyToClipboard" ;
7
6
import hljs from "highlight.js" ;
8
7
@@ -33,7 +32,7 @@ const LANGUAGES_SUBSET_DETECTION = [
33
32
34
33
interface Props {
35
34
children : string ;
36
- className ?: string ;
35
+ isInverted ?: boolean ;
37
36
}
38
37
39
38
const customStyle = {
@@ -52,9 +51,11 @@ const customStyle = {
52
51
boxSizing : "border-box" ,
53
52
} ,
54
53
} ;
55
- export function Markdown ( { children, className = "" } : Props ) {
54
+
55
+ export function Markdown ( { children, isInverted = false } : Props ) {
56
56
return (
57
57
< ReactMarkdown
58
+ className = { `max-w-none prose prose-pre:shadow-md prose-pre:rounded-lg prose-pre:p-4 prose-p:leading-relaxed prose-h1:text-3xl prose-h1:font-bold prose-h1:mb-8 prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-8 prose-h2:mb-4 prose-h3:text-xl prose-h3:font-medium prose-h3:mt-6 prose-h3:mb-3 ${ isInverted ? "prose-invert" : "" } ` }
58
59
components = { {
59
60
code ( { className, children, ...props } ) {
60
61
if ( ! children ) return null ;
@@ -71,7 +72,7 @@ export function Markdown({ children, className = "" }: Props) {
71
72
< SyntaxHighlighter
72
73
style = { customStyle }
73
74
language = { language }
74
- PreTag = "div "
75
+ PreTag = "pre "
75
76
className = "rounded-lg overflow-hidden shadow-lg text-sm my-6 whitespace-normal"
76
77
wrapLines
77
78
{ ...props }
@@ -84,22 +85,9 @@ export function Markdown({ children, className = "" }: Props) {
84
85
</ div >
85
86
) ;
86
87
} ,
87
- p ( { children } ) {
88
- return (
89
- < p
90
- className = { cn (
91
- "text-gray-600 leading-relaxed mt-6 mb-3" ,
92
- className ,
93
- ) }
94
- >
95
- { children }
96
- </ p >
97
- ) ;
98
- } ,
99
88
pre ( { children } ) {
100
- return < div className = "not-prose" > { children } </ div > ;
89
+ return children ;
101
90
} ,
102
-
103
91
a ( { children, ...props } ) {
104
92
return (
105
93
< a
@@ -116,7 +104,6 @@ export function Markdown({ children, className = "" }: Props) {
116
104
} ,
117
105
} }
118
106
remarkPlugins = { [ remarkGfm ] }
119
- className = { className }
120
107
>
121
108
{ children }
122
109
</ ReactMarkdown >
0 commit comments