@udus/notion-renderer
Version:

20 lines (19 loc) • 1.01 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useEffect } from "react";
import { RichText } from "../RichText/RichText.js";
export const Embed = ({ block }) => {
useEffect(() => {
const script = document.createElement("script");
script.src = "https://platform.twitter.com/widgets.js";
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, []);
if (block.embed.oembed) {
return (_jsx("div", { className: "notion-block notion-embed", dangerouslySetInnerHTML: {
__html: block.embed.oembed.type === "rich" ? block.embed.oembed.html : "",
} }));
}
return (_jsxs("div", { id: block.id, className: "notion-block notion-embed", children: [_jsx("iframe", { src: block.embed.url, title: "notion embed content" }), _jsx("div", { className: "notion-caption notion-embed-caption", children: _jsx(RichText, { richText: block.embed.caption }) })] }));
};