diff --git a/web/docs/_example/page.mdx b/web/docs/_example/page.mdx index 995d165..5528ff1 100644 --- a/web/docs/_example/page.mdx +++ b/web/docs/_example/page.mdx @@ -20,15 +20,32 @@ Nice Diagram ```mermaid -gantt - title A Gantt Diagram - dateFormat YYYY-MM-DD - section Section - A task :a1, 2014-01-01, 30d - Another task :after a1, 20d - section Another - Task in Another :2014-01-12, 12d - another task :24d +--- +title: Animal example +--- +classDiagram + note "From Duck till Zebra" + Animal <|-- Duck + note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging" + Animal <|-- Fish + Animal <|-- Zebra + Animal : +int age + Animal : +String gender + Animal: +isMammal() + Animal: +mate() + class Duck{ + +String beakColor + +swim() + +quack() + } + class Fish{ + -int sizeInFeet + -canEat() + } + class Zebra{ + +bool is_wild + +run() + } ``` Some code diff --git a/web/src/app/docs/[[...slug]]/page.tsx b/web/src/app/docs/[[...slug]]/page.tsx index abff799..22bbe58 100644 --- a/web/src/app/docs/[[...slug]]/page.tsx +++ b/web/src/app/docs/[[...slug]]/page.tsx @@ -163,7 +163,7 @@ export default async function Page({ params }: Props) {
-
+
{metadata.title} diff --git a/web/src/components/mermaid.tsx b/web/src/components/mermaid.tsx index bca7bca..573b1c9 100644 --- a/web/src/components/mermaid.tsx +++ b/web/src/components/mermaid.tsx @@ -2,6 +2,7 @@ import clsx from "clsx"; import { useEffect, useState } from "react"; import mermaid from "mermaid"; +import { useTheme } from "next-themes"; type Props = { code: string; @@ -10,20 +11,40 @@ type Props = { let loaded = false; const Mermaid = ({ code }: Props) => { + const { theme } = useTheme(); + const [svg, setSvg] = useState(""); + useEffect(() => { - if (!loaded) { + const init = async () => { mermaid.initialize({ - startOnLoad: true, - darkMode: true, + startOnLoad: false, + //theme: "base", + //darkMode: false, + themeVariables: { + //fontFamily: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji', + //fontSize: "32px", + }, }); + const { svg } = await mermaid.render("graphDiv", code); + setSvg(svg); + }; + + if (!loaded) { + console.log(theme); + init(); loaded = true; } - }, []); + + }, [code]); return ( -
-
{code}
-
+
); };