From 7c09627df4bd61e3b4fbd6fd84a1971b40ff72b3 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sat, 05 Aug 2023 22:34:10 +0000
Subject: [PATCH] improve hot reload robustness
---
quartz/plugins/transformers/ofm.ts | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index 70155e0..13a32ca 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -184,7 +184,7 @@
// embed cases
if (value.startsWith("!")) {
- const ext: string | undefined = path.extname(fp).toLowerCase()
+ const ext: string = path.extname(fp).toLowerCase()
const url = slugifyFilePath(fp as FilePath) + ext
if ([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg"].includes(ext)) {
const dims = alias ?? ""
@@ -218,8 +218,8 @@
type: "html",
value: `<iframe src="${url}"></iframe>`,
}
- } else {
- // TODO: this is the node embed case
+ } else if (ext === "") {
+ // TODO: note embed
}
// otherwise, fall through to regular link
}
@@ -414,7 +414,13 @@
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",
--
Gitblit v1.10.0