Explorar o código

fix: handle anchor links within the page contents (#1006)

Nick %!s(int64=5) %!d(string=hai) anos
pai
achega
cc469d8785
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      client/themes/default/components/page.vue

+ 8 - 0
client/themes/default/components/page.vue

@@ -314,6 +314,14 @@ export default {
       if (window.location.hash && window.location.hash.length > 1) {
         this.$vuetify.goTo(window.location.hash, this.scrollOpts)
       }
+
+      this.$refs.container.querySelectorAll(`a[href^="#"], a[href^="${window.location.href.replace(window.location.hash, '')}#"]`).forEach(el => {
+        el.onclick = ev => {
+          ev.preventDefault()
+          ev.stopPropagation()
+          this.$vuetify.goTo(ev.target.hash, this.scrollOpts)
+        }
+      })
     })
   },
   methods: {