@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
33import { codeToHtml } from "shiki" ;
44
55import { Button } from "@/components/ui/button" ;
6+ import { cn } from "@/utils/utils" ;
67
78interface CodeBlockProps {
89 children : React . ReactNode ;
@@ -52,7 +53,12 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
5253
5354 if ( isInline ) {
5455 return (
55- < code className = "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold" >
56+ < code
57+ className = { cn (
58+ "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold" ,
59+ className
60+ ) }
61+ >
5662 { children }
5763 </ code >
5864 ) ;
@@ -71,7 +77,12 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
7177 if ( isLoading ) {
7278 return (
7379 < div className = "relative group" >
74- < pre className = "mb-4 mt-6 overflow-x-auto rounded-lg border bg-zinc-950 text-white p-4" >
80+ < pre
81+ className = { cn (
82+ "mb-4 mt-6 overflow-x-auto rounded-lg border bg-zinc-950 text-white p-4" ,
83+ className
84+ ) }
85+ >
7586 < div className = "flex items-center justify-center h-20" >
7687 < div className = "text-zinc-400 text-sm" >
7788 Loading syntax highlighting...
@@ -93,7 +104,10 @@ export function CodeBlock({ children, className, language }: CodeBlockProps) {
93104 { copied ? < Check className = "h-4 w-4" /> : < Copy className = "h-4 w-4" /> }
94105 </ Button >
95106 < div
96- className = "mb-4 mt-2 overflow-x-auto rounded-md text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre-wrap"
107+ className = { cn (
108+ "mb-4 mt-2 overflow-x-auto rounded-md text-sm [&_pre]:m-0 [&_pre]:p-4 [&_pre]:!bg-secondary [&_pre]:dark:!bg-neutral-900 [&_code]:whitespace-pre-wrap" ,
109+ className
110+ ) }
97111 dangerouslySetInnerHTML = { { __html : highlightedCode } }
98112 />
99113 </ div >
0 commit comments