mirror of
https://github.com/usememos/memos.git
synced 2025-10-09 13:56:40 +08:00
chore: tweak theme code
This commit is contained in:
parent
94517490f5
commit
cde058c72a
1 changed files with 2 additions and 4 deletions
|
@ -6,16 +6,14 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const MermaidBlock: React.FC<Props> = ({ content }: Props) => {
|
const MermaidBlock: React.FC<Props> = ({ content }: Props) => {
|
||||||
|
const { mode: colorMode } = useColorScheme();
|
||||||
const mermaidDockBlock = useRef<null>(null);
|
const mermaidDockBlock = useRef<null>(null);
|
||||||
const { mode } = useColorScheme();
|
|
||||||
|
|
||||||
const mermaidTheme = mode == "dark" ? "dark" : "default";
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Dynamically import mermaid to ensure compatibility with Vite
|
// Dynamically import mermaid to ensure compatibility with Vite
|
||||||
const initializeMermaid = async () => {
|
const initializeMermaid = async () => {
|
||||||
const mermaid = (await import("mermaid")).default;
|
const mermaid = (await import("mermaid")).default;
|
||||||
mermaid.initialize({ startOnLoad: false, theme: mermaidTheme });
|
mermaid.initialize({ startOnLoad: false, theme: colorMode == "dark" ? "dark" : "default" });
|
||||||
if (mermaidDockBlock.current) {
|
if (mermaidDockBlock.current) {
|
||||||
mermaid.run({
|
mermaid.run({
|
||||||
nodes: [mermaidDockBlock.current],
|
nodes: [mermaidDockBlock.current],
|
||||||
|
|
Loading…
Add table
Reference in a new issue