import type { ReactNode } from 'react'; import { highlight } from '@/core/highlight'; import { CopyButton } from './copy-button'; const languages = { tsx: { label: 'TSX', icon: ( ), }, css: { label: 'CSS', icon: ( ), }, sh: { label: 'Terminal', icon: ( ), }, } satisfies Record; export type CodeLanguage = keyof typeof languages; export function isCodeLanguage(value: string): value is CodeLanguage { return Object.hasOwn(languages, value); } export async function CodeBlock({ code, lang }: { code: string; lang: CodeLanguage }) { const html = await highlight(code, lang); const language = languages[lang]; return (
{language.icon} {language.label}
); }