diff --git a/src/components/ui/Mermaid.tsx b/src/components/ui/Mermaid.tsx index 82f30d2d..2452e7c8 100644 --- a/src/components/ui/Mermaid.tsx +++ b/src/components/ui/Mermaid.tsx @@ -4,18 +4,16 @@ import { nanoid } from "nanoid" import { memo, useEffect, useState } from "react" import { useIsDark } from "~/hooks/useDarkMode" -import { useIsUnmounted } from "~/hooks/useLifecycle" import AdvancedImage from "./AdvancedImage" const Mermaid = memo( - function Mermaid(props: { children: [string] }) { + function Mermaid(props: { children: string }) { const [loading, setLoading] = useState(true) const [error, setError] = useState("") const [svg, setSvg] = useState("") const [width, setWidth] = useState() const [height, setHeight] = useState() - const isUnmounted = useIsUnmounted() const isDark = useIsDark() @@ -29,7 +27,7 @@ const Mermaid = memo( }, [isDark]) useEffect(() => { - if (props.children?.[0]) { + if (typeof props.children === "string") { setError("") setLoading(true) @@ -38,7 +36,7 @@ const Mermaid = memo( const id = nanoid() let result try { - result = await mermaid.render(`mermaid-${id}`, props.children[0]) + result = await mermaid.render(`mermaid-${id}`, props.children) } catch (error) { document.getElementById(`dmermaid-${id}`)?.remove() if (error instanceof Error) { @@ -49,8 +47,6 @@ const Mermaid = memo( setHeight(undefined) } - if (isUnmounted()) return - if (result) { setSvg(result.svg) @@ -66,7 +62,7 @@ const Mermaid = memo( setLoading(false) }) } - }, [props.children, isDark]) + }, [props.children]) return loading ? (
diff --git a/src/markdown/index.ts b/src/markdown/index.ts index 78806f7f..534372a7 100644 --- a/src/markdown/index.ts +++ b/src/markdown/index.ts @@ -220,8 +220,6 @@ export const renderPageContent = (content: string, strictMode?: boolean) => { ignoreInvalidStyle: true, jsx, jsxs, - passKeys: true, - passNode: true, }), toMetadata: () => { let metadata = {