2024-12-16 18:14:40 +05:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
interface CodeBlockProps {
|
|
|
|
|
node: any;
|
|
|
|
|
inline: boolean;
|
|
|
|
|
className: string;
|
|
|
|
|
children: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CodeBlock({
|
|
|
|
|
node,
|
|
|
|
|
inline,
|
|
|
|
|
className,
|
|
|
|
|
children,
|
|
|
|
|
...props
|
|
|
|
|
}: CodeBlockProps) {
|
|
|
|
|
if (!inline) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="not-prose flex flex-col">
|
2025-02-13 08:25:57 -08:00
|
|
|
<pre
|
|
|
|
|
{...props}
|
|
|
|
|
className={`text-sm w-full overflow-x-auto dark:bg-zinc-900 p-4 border border-zinc-200 dark:border-zinc-700 rounded-xl dark:text-zinc-50 text-zinc-900`}
|
|
|
|
|
>
|
|
|
|
|
<code className="whitespace-pre-wrap break-words">{children}</code>
|
|
|
|
|
</pre>
|
2024-12-16 18:14:40 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<code
|
|
|
|
|
className={`${className} text-sm bg-zinc-100 dark:bg-zinc-800 py-0.5 px-1 rounded-md`}
|
|
|
|
|
{...props}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</code>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|