From 9e76b257d4be4b9e6ea7b514074ef74d8d125f4b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Fri, 4 Aug 2023 22:35:21 -0700 Subject: [PATCH] fix mermaid initialization --- quartz/bootstrap-cli.mjs | 3 +-- quartz/plugins/transformers/ofm.ts | 8 +++++++- quartz/styles/base.scss | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 0bb078a9d..0094a4fe7 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -121,7 +121,7 @@ async function popContentFolder(contentFolder) { } function gitPull(origin, branch) { - const flags = ["-s", "recursive", "-X", "ours"] + const flags = ["-s", "recursive", "-X", "ours", "--no-edit"] spawnSync("git", ["pull", ...flags, origin, branch], { stdio: "inherit" }) } @@ -334,7 +334,6 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. sourcefile, }, write: false, - minify: true, bundle: true, platform: "browser", format: "esm", diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 70155e0de..a9beda4da 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -414,7 +414,13 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin js.push({ script: ` import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs'; - mermaid.initialize({ startOnLoad: true }); + document.addEventListener('nav', async () => { + const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark' + mermaid.initialize({ + securityLevel: 'loose', + theme: darkMode ? 'dark' : 'default' + }); + }); `, loadTime: "afterDOMReady", moduleType: "module", diff --git a/quartz/styles/base.scss b/quartz/styles/base.scss index 8253c5b8f..729193967 100644 --- a/quartz/styles/base.scss +++ b/quartz/styles/base.scss @@ -310,6 +310,7 @@ pre { &:has(> code.mermaid) { border: none; + position: relative; } & > code {