import * as React from "react"; import { useRemark } from "react-remark"; import { Anchor } from "../Anchor/Anchor"; import { Header, Text, TextVariant } from "../Text/Text"; function getRehypeOptions(props: MarkdownProps) { const { textVariant = "text-md/normal" } = props; return { components: { h1: (props: any) =>
, h2: (props: any) =>
, h3: (props: any) =>
, h4: (props: any) =>
, h5: (props: any) =>
, p: (props: any) => , a: (props: any) => , }, }; } export interface MarkdownProps { children: string; textVariant?: TextVariant; } export function Markdown(props: MarkdownProps) { const { children } = props; const [renderedContent, setContent] = useRemark({ rehypeReactOptions: getRehypeOptions(props) }); React.useEffect(() => { setContent(children); }, [children, setContent]); return <>{renderedContent}; }