UNPKG

@udus/notion-renderer

Version:
23 lines (22 loc) 1.43 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { extractTitle } from "../../utils/index.js"; import { Icon } from "../Common/Icon.js"; import { useMapper } from "../hooks.js"; import { RichText } from "../RichText/RichText.js"; export const LinkToPage = ({ block }) => { const { Link } = useMapper(); if (block.link_to_page.type === "comment_id" && block.link_to_page.comments) { console.warn("comment type link_to_page block is not supported yet."); } const icon = block.link_to_page.type === "page_id" && block.link_to_page.page ? block.link_to_page.page.icon : block.link_to_page.type === "database_id" && block.link_to_page.database ? block.link_to_page.database.icon : null; const titleRichText = block.link_to_page.type === "page_id" && block.link_to_page.page ? extractTitle(block.link_to_page.page) : block.link_to_page.type === "database_id" && block.link_to_page.database ? extractTitle(block.link_to_page.database) : []; return (_jsx("div", { id: block.id, className: "notion-block notion-link-to-page", children: _jsxs(Link, { prefix: "/", link: block.id, children: [_jsx("span", { className: "notion-link-to-page-icon", children: _jsx(Icon, { icon: icon }) }), _jsx("span", { className: "notion-link-to-page-title", children: _jsx(RichText, { richText: titleRichText }) })] }) })); };