Skip to content

Commit 9662f2b

Browse files
committed
fix: adjust img, code and blockquote margins on markdown content
1 parent 80cf746 commit 9662f2b

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

web/src/modules/shared/components/CustomMarkdown.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const CustomMarkdown = ({
2424
pre,
2525
code,
2626
a,
27+
img,
2728
}}
2829
>
2930
{MarkdownContent}
@@ -82,7 +83,7 @@ const blockquote = ({
8283
return (
8384
<blockquote
8485
{...props}
85-
className='border-l-4 border-zinc-600 bg-zinc-800/50 rounded-md [&>p]:text-zinc-400 pl-4 [&>p]:py-2'
86+
className='border-l-4 border-zinc-600 bg-zinc-800/50 rounded-md [&>p]:text-zinc-400 pl-4 [&>p]:py-2 my-6'
8687
/>
8788
);
8889
};
@@ -103,7 +104,7 @@ const code = ({
103104
return (
104105
<code
105106
{...props}
106-
className='bg-zinc-950/50 text-green-400 rounded-md outline outline-1 outline-zinc-600 text-sm font-mono px-1 py-0.5'
107+
className='bg-zinc-950/50 text-green-400 rounded-md outline outline-1 outline-zinc-600 text-sm font-mono px-1 py-0.5 mx-0.5'
107108
/>
108109
);
109110
};
@@ -122,4 +123,32 @@ const a = ({
122123
);
123124
};
124125

125-
export { p, h1, h2, h3, h4, h5, h6, hr, ul, ol, li, blockquote, pre, code, a };
126+
const img = ({
127+
node,
128+
alt,
129+
src = '',
130+
...props
131+
}: JSX.IntrinsicElements['img'] & ExtraProps) => {
132+
return (
133+
<img {...props} alt={alt} src={src} className='my-8 mx-auto rounded-lg' />
134+
);
135+
};
136+
137+
export {
138+
p,
139+
h1,
140+
h2,
141+
h3,
142+
h4,
143+
h5,
144+
h6,
145+
hr,
146+
ul,
147+
ol,
148+
li,
149+
blockquote,
150+
pre,
151+
code,
152+
a,
153+
img,
154+
};

0 commit comments

Comments
 (0)