({ block }: { block: any })
| 8 | import { Copy } from "lucide-react"; |
| 9 | |
| 10 | export default function CodeBlock({ block }: { block: any }) { |
| 11 | const { toast } = useToast(); |
| 12 | |
| 13 | const code: string = block.properties.title[0].toString(); |
| 14 | hljs.registerLanguage("javascript", javascript); |
| 15 | |
| 16 | useEffect(() => { |
| 17 | hljs.highlightAll(); |
| 18 | }, []); |
| 19 | |
| 20 | const handleCopyClick = () => { |
| 21 | navigator.clipboard.writeText(code).then(() => { |
| 22 | toast({ |
| 23 | description: "Copied to clipboard", |
| 24 | }); |
| 25 | }); |
| 26 | }; |
| 27 | |
| 28 | return ( |
| 29 | <div className="w-full relative"> |
| 30 | <div className="absolute rounded-s-md w-1 inset-y-0 bg-gradient-to-b from-blue-400 to-blue-700" /> |
| 31 | <pre className="rounded-md text-sm sm:text-base !bg-[#151515] px-4 sm:px-6 md:px-8 whitespace-pre-wrap break-word flex justify-between"> |
| 32 | <code className="language-javascript">{code}</code> |
| 33 | </pre> |
| 34 | <button className="text-gray-500 p-2 absolute top-2 right-2 hover:opacity-80" onClick={handleCopyClick}> |
| 35 | <Copy className="size-5 text-primary/50" /> |
| 36 | </button> |
| 37 | </div> |
| 38 | ); |
| 39 | } |
nothing calls this directly
no test coverage detected