import React from "react"; import { NotionAPIBlock } from "@/@types/NotionAPIBlock"; import { NotionBlockMap } from "@/@types/NotionBlockMap"; interface NotionRendererProps { blocks: NotionAPIBlock[]; } type NotionRendererFactory = (map: NotionBlockMap) => { NotionRenderer: React.FC; }; /** * Create a notion renderer object. * @param map The Notion-local component map. * @returns A renderer JSX element. */ export const makeNotionRenderer: NotionRendererFactory = (map) => { const NotionRenderer = ({ blocks }: NotionRendererProps) => { const response: NotionAPIBlock[] = blocks; return ( <> {response.map((props) => { const { type } = props; const Block = map[type] as React.FC; if (!Block) return void 0; return ; })} ); }; return { NotionRenderer }; };