Files
zeekay f21b520d17 fix: Correct snippet component reference and fix syntax highlighting
- Update snippet.mdx to reference correct component name (code-snippet-demo)
- Create proper working demo for CodeSnippet component with TypeScript example
- Fix syntax highlighting by updating to Shiki v3 API with bundledLanguages
- Add language validation to prevent unsupported language errors
- Improve error handling with HTML escaping fallback
- Rebuild registry with updated component
2025-11-06 13:45:30 -08:00

28 lines
631 B
TypeScript

"use client"
import { CodeSnippet } from "@/registry/default/ui/code-snippet"
const exampleCode = `function fibonacci(n: number): number {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
// Calculate the 10th Fibonacci number
const result = fibonacci(10);
console.log(\`Fibonacci(10) = \${result}\`);`
export default function CodeSnippetDemo() {
return (
<div className="w-full space-y-6">
<CodeSnippet
code={exampleCode}
language="typescript"
filename="fibonacci.ts"
showLineNumbers
showCopyButton
showLanguageBadge
/>
</div>
)
}