From 76c092dcf20959bc52fcb13b28cee50cd4217e40 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 20 Jul 2023 04:59:48 +0000
Subject: [PATCH] add custom.scss

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

diff --git a/quartz/components/scripts/spa.inline.ts b/quartz/components/scripts/spa.inline.ts
index 057aa3d..774326e 100644
--- a/quartz/components/scripts/spa.inline.ts
+++ b/quartz/components/scripts/spa.inline.ts
@@ -1,4 +1,5 @@
 import micromorph from "micromorph"
+import { CanonicalSlug, RelativeURL, getCanonicalSlug } from "../../path"
 
 // adapted from `micromorph`
 // https://github.com/natemoo-re/micromorph
@@ -29,7 +30,7 @@
   return { url: new URL(href), scroll: 'routerNoscroll' in a.dataset ? false : undefined }
 }
 
-function notifyNav(url: string) {
+function notifyNav(url: CanonicalSlug) {
   const event: CustomEventMap["nav"] = new CustomEvent("nav", { detail: { url } })
   document.dispatchEvent(event)
 }
@@ -42,6 +43,7 @@
     .catch(() => {
       window.location.assign(url)
     })
+
   if (!contents) return;
   if (!isBack) {
     history.pushState({}, "", url)
@@ -69,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
 }
 
@@ -100,7 +102,7 @@
   }
 
   return new class Router {
-    go(pathname: string) {
+    go(pathname: RelativeURL) {
       const url = new URL(pathname, window.location.toString())
       return navigate(url, false)
     }
@@ -116,7 +118,7 @@
 }
 
 createRouter()
-notifyNav(document.body.dataset.slug!)
+notifyNav(getCanonicalSlug(window))
 
 if (!customElements.get('route-announcer')) {
   const attrs = {

--
Gitblit v1.10.0