mirror of
				https://github.com/ZetaKebab/quartz.git
				synced 2025-11-04 06:49:49 +00:00 
			
		
		
		
	fix: nav event with spa off, anchor nav refresh page
This commit is contained in:
		@@ -12,9 +12,6 @@ const isLocalUrl = (href: string) => {
 | 
			
		||||
  try {
 | 
			
		||||
    const url = new URL(href)
 | 
			
		||||
    if (window.location.origin === url.origin) {
 | 
			
		||||
      if (url.pathname === window.location.pathname) {
 | 
			
		||||
        return !url.hash
 | 
			
		||||
      }
 | 
			
		||||
      return true
 | 
			
		||||
    }
 | 
			
		||||
  } catch (e) {}
 | 
			
		||||
@@ -94,7 +91,6 @@ function createRouter() {
 | 
			
		||||
    window.addEventListener("click", async (event) => {
 | 
			
		||||
      const { url } = getOpts(event) ?? {}
 | 
			
		||||
      if (!url) return
 | 
			
		||||
      if (url.pathname === window.location.pathname) return
 | 
			
		||||
      event.preventDefault()
 | 
			
		||||
      try {
 | 
			
		||||
        navigate(url, false)
 | 
			
		||||
 
 | 
			
		||||
@@ -103,7 +103,7 @@ function addGlobalPageResources(
 | 
			
		||||
  } else {
 | 
			
		||||
    componentResources.afterDOMLoaded.push(`
 | 
			
		||||
        window.spaNavigate = (url, _) => window.location.assign(url)
 | 
			
		||||
        const event = new CustomEvent("nav", { detail: { slug: document.body.dataset.slug } })
 | 
			
		||||
        const event = new CustomEvent("nav", { detail: { url: document.body.dataset.slug } })
 | 
			
		||||
        document.dispatchEvent(event)`)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user