diff --git a/content/.gitkeep b/content/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/content/index.md b/content/index.md new file mode 100644 index 000000000..2bdfd8337 --- /dev/null +++ b/content/index.md @@ -0,0 +1,6 @@ +--- +title: Welcome to Quartz +--- + +This is a blank Quartz installation. +See the [documentation](https://quartz.jzhao.xyz) for how to get started. diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts index 6bf43aa84..200c1331e 100644 --- a/quartz/components/scripts/graph.inline.ts +++ b/quartz/components/scripts/graph.inline.ts @@ -190,6 +190,18 @@ async function renderGraph(container: string, fullSlug: FullSlug) { {} as Record<(typeof cssVars)[number], string>, ) + function updateTextStyle() { + const darkMode = document.documentElement.getAttribute("saved-theme") === "dark" + const textColor = darkMode ? computedStyleMap["--dark"] : computedStyleMap["--light"] + + for (const n of nodeRenderData) { + n.label.style.fill = textColor + } + } + + document.addEventListener("themechange", updateTextStyle) + window.addCleanup(() => document.removeEventListener("themechange", updateTextStyle)) + // calculate color const color = (d: NodeData) => { const isCurrent = d.id === slug @@ -426,6 +438,7 @@ async function renderGraph(container: string, fullSlug: FullSlug) { } nodeRenderData.push(nodeRenderDatum) + updateTextStyle() } for (const l of graphData.links) { @@ -542,7 +555,7 @@ async function renderGraph(container: string, fullSlug: FullSlug) { } const graphAnimationFrameHandle = requestAnimationFrame(animate) - window.addCleanup(() => cancelAnimationFrame(graphAnimationFrameHandle)) + window.addCleanup(() => document.removeEventListener("themechange", updateTextStyle)) } document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { @@ -585,4 +598,4 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => { document.addEventListener("keydown", shortcutHandler) window.addCleanup(() => document.removeEventListener("keydown", shortcutHandler)) -}) +}) \ No newline at end of file