import { RichTextItemResponse } from "@notionhq/client/build/src/api-endpoints"; import React from "react"; export const RichText = ({ rich_text, }: { rich_text: RichTextItemResponse[]; }) => { return ( <> {rich_text.map((rich_text_item, index) => { if (!rich_text_item) return <>; const { bold, italic, strikethrough, underline, code } = rich_text_item.annotations; const color = rich_text_item.annotations.color.includes("background") ? { backgroundColor: rich_text_item.annotations.color.split("_")[0] } : { color: rich_text_item.annotations.color }; let text = {rich_text_item.plain_text}; if (bold) { text = {text}; } if (italic) { text = {text}; } if (strikethrough) { text = {text}; } if (underline) { text = {text}; } if (code) { // Remove "`" from text text = {text}; } if (rich_text_item.href) { text = ( {text} ); } return ( {text} ); })} ); };