fix: handle hash navigation to prevent duplicate callbacks (#2575)

This commit is contained in:
Luffy 2025-07-24 11:00:20 +08:00 committed by GitHub
parent 84ba4686ed
commit 72569dee8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -917,7 +917,7 @@ If you have a link to the homepage in the sidebar and want it to be shown as act
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
## themeColor ⚠️
## themeColor ⚠️ :id=themecolor
!> Deprecated as of v5. Use the `--theme-color` [theme property](themes#theme-properties) to [customize](themes#customization) your theme color.
@ -931,7 +931,7 @@ window.$docsify = {
};
```
## topMargin ⚠️
## topMargin ⚠️ :id=topmargin
!> Deprecated as of v5. Use the `--scroll-padding-top` [theme property](themes#theme-properties) to specify a scroll margin when using a sticky navbar.

View File

@ -47,6 +47,15 @@ export class HashHistory extends History {
if (el && el.tagName === 'A' && !isExternal(el.href)) {
navigating = true;
// Do not compare hash containing these classes.
if (['app-name-link', 'page-link'].includes(el.className)) {
return;
}
if (el.hash === location.hash) {
cb({ event: e, source: 'navigate' });
}
}
});