vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.33k stars 1.83k forks source link

fix: hashchange should only be triggered for same page navigations #3768

Closed brc-dd closed 2 weeks ago

brc-dd commented 2 weeks ago

reverts parts of https://github.com/vuejs/vitepress/compare/f6bd99eb1311238e1114301a767634b139327916...49ea062b3984440b98aeb1158b390d92d7fe4670

The original implementation by zonemeen was correct - https://github.com/vuejs/vitepress/pull/3637/commits/59e177362306bf9947c6854315374ffd2ea465ad

hashchange should not be triggered when navigating between different pages

This PR also adds hash property in useData output for those who want to watch for hash change while navigating between pages - say from /foo#bar to /. Those who don't want this should stick with window.addEventListener('hashchange', ...)

It also emits correct event instance with oldURL and newURL for hashchange now.