import { mutedDark, mutedLight } from '@/app/theme';
import { html, type Options } from '@/app/html';
import styles from './CodeBlock.module.scss';

type CodeBlockOptions = Options & {
    muted?: boolean;
};

export function CodeBlock({ file, lang, themes, muted = false }: CodeBlockOptions) {
    const code = html({
        file,
        lang,
        themes: muted ? { light: mutedLight, dark: mutedDark } : themes,
    });

    return <div className={styles['code-block']} dangerouslySetInnerHTML={{ __html: code }} />;
}