import { type RichTextItemResponse } from '@notionhq/client/build/src/api-endpoints' import clsx from 'clsx' import dynamic from 'next/dynamic' import { type FC, Suspense } from 'react' import HybridLink from './HybridLink' const TeX = dynamic(() => import('@matejmazur/react-katex')) const RichText: FC<{ richText: RichTextItemResponse[] }> = ({ richText }) => { return ( <> {richText.map((text, index) => { if (text.type === 'mention') return null // TODO else if (text.type === 'text') { const className = clsx({ italic: text.annotations.italic, 'font-bold': text.annotations.bold, underline: text.annotations.underline, 'dark:bg-neutral-800 border-1 dark:border-neutral-500 font-mono dark:text-red-400 p-1 rounded': text.annotations.code, }) if (text.href) { return ( {text.plain_text} ) } const Tag = text.annotations.strikethrough ? 's' : 'span' return ( {text.plain_text} ) } else if (text.type === 'equation') return ( {text.equation.expression} ) })} ) } export default RichText