import Prism, { highlight } from 'prismjs' import { type PropsWithChildren } from 'react' import { RichText } from '@/lib/notion/types' import richTextAsPlainText from '@/lib/notion/utils/richTextToPlainText' export interface Props { language: string codeRichText: RichText } /** * This is only used for the RSS feed */ export function SyncCodeSnippet({ language, codeRichText, }: PropsWithChildren) { const highlightedCodeHtml = highlight( richTextAsPlainText(codeRichText), Prism.languages[language], language, ) return (
      
    
) } export default async function CodeSnippet(props: PropsWithChildren) { await import(`prismjs/components/prism-${props.language}.min.js`) // @ts-expect-error CSS not JS await import('prismjs/themes/prism-tomorrow.min.css') // @ts-expect-error CSS not JS await import('prismjs/themes/prism.min.css') return }