import React from 'react'; import { cn } from '../../lib/utils'; import { FiCopy, FiCheck } from 'react-icons/fi'; import { Button } from './Button'; interface CodeBlockProps { code: string; language?: string; showLineNumbers?: boolean; className?: string; } export const CodeBlock: React.FC = ({ code, language = 'typescript', showLineNumbers = false, className, }) => { const [copied, setCopied] = React.useState(false); const handleCopy = async () => { await navigator.clipboard.writeText(code); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const lines = code.split('\n'); return (
{language && (
{language}
)}
          
            {showLineNumbers
              ? lines.map((line, index) => (
                  
{index + 1} {line || '\n'}
)) : code}
); };