diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 00c98531..7370d9e3 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -180,7 +180,7 @@ export function createRouter( : link.href, link.baseURI ) - const currentUrl = window.location + const currentUrl = new URL(window.location.href) // copy to keep old data // only intercept inbound html links if ( !e.ctrlKey && @@ -211,7 +211,12 @@ export function createRouter( window.scrollTo(0, 0) } } else { - go(href) + go(href).then(() => { + // do after the route is changed so location.hash in theme code is the new hash + if (hash !== currentUrl.hash) { + window.dispatchEvent(new Event('hashchange')) + } + }) } } } diff --git a/src/client/theme-default/composables/langs.ts b/src/client/theme-default/composables/langs.ts index c28a58d4..4d105cd7 100644 --- a/src/client/theme-default/composables/langs.ts +++ b/src/client/theme-default/composables/langs.ts @@ -1,4 +1,4 @@ -import { computed, watch } from 'vue' +import { computed } from 'vue' import { ensureStartingSlash } from '../support/utils' import { useData } from './data' import { hashRef } from './hash' @@ -15,10 +15,6 @@ export function useLangs({ (localeIndex.value === 'root' ? '/' : `/${localeIndex.value}/`) })) - watch(page, () => { - hashRef.value = location.hash ? location.hash : '' - }) - const localeLinks = computed(() => Object.entries(site.value.locales).flatMap(([key, value]) => removeCurrent && currentLang.value.label === value.label