From 3ac6b42e16dca5a44ed3fec2c0314f1dbbc2322b Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 16 Jul 2023 06:02:12 +0000
Subject: [PATCH] finish path refactoring, add sourcemap + better trace support

---
 quartz/components/scripts/spa.inline.ts |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/quartz/components/scripts/spa.inline.ts b/quartz/components/scripts/spa.inline.ts
index 5ba53e3..774326e 100644
--- a/quartz/components/scripts/spa.inline.ts
+++ b/quartz/components/scripts/spa.inline.ts
@@ -1,5 +1,5 @@
 import micromorph from "micromorph"
-import { CanonicalSlug, RelativeURL } from "../../path"
+import { CanonicalSlug, RelativeURL, getCanonicalSlug } from "../../path"
 
 // adapted from `micromorph`
 // https://github.com/natemoo-re/micromorph
@@ -43,6 +43,7 @@
     .catch(() => {
       window.location.assign(url)
     })
+
   if (!contents) return;
   if (!isBack) {
     history.pushState({}, "", url)
@@ -70,7 +71,7 @@
   const elementsToAdd = html.head.querySelectorAll(':not([spa-preserve])')
   elementsToAdd.forEach(el => document.head.appendChild(el))
 
-  notifyNav(document.body.dataset.slug!)
+  notifyNav(getCanonicalSlug(window))
   delete announcer.dataset.persist
 }
 
@@ -117,7 +118,7 @@
 }
 
 createRouter()
-notifyNav(document.body.dataset.slug!)
+notifyNav(getCanonicalSlug(window))
 
 if (!customElements.get('route-announcer')) {
   const attrs = {

--
Gitblit v1.10.0