Skip to content

Commit

Permalink
fix: Reload graph after a theme change (closes jackyzha0#1380) (jacky…
Browse files Browse the repository at this point in the history
…zha0#1383)

* FIX: Reload graph after a theme change

* FIX: Reload graph after a theme change - comment updated

* FIX: Reload graph after a theme change - comment updated

* FIX: Reload graph after a theme change

* fix: Reload graph after a theme change
  • Loading branch information
MarcRez33 authored Aug 31, 2024
1 parent 84a9be6 commit 01fc26d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions quartz/components/scripts/graph.inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,19 @@ document.addEventListener("nav", async (e: CustomEventMap["nav"]) => {
addToVisited(simplifySlug(slug))
await renderGraph("graph-container", slug)

// Function to re-render the graph when the theme changes
const handleThemeChange = () => {
renderGraph("graph-container", slug)
}

// event listener for theme change
document.addEventListener("themechange", handleThemeChange)

// cleanup for the event listener
window.addCleanup(() => {
document.removeEventListener("themechange", handleThemeChange)
})

const container = document.getElementById("global-graph-outer")
const sidebar = container?.closest(".sidebar") as HTMLElement

Expand Down

0 comments on commit 01fc26d

Please sign in to comment.