File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/components/modules/toc Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,12 @@ function useActiveId($headings: HTMLHeadingElement[]) {
31
31
entries . forEach ( ( entry ) => {
32
32
if ( entry . isIntersecting ) {
33
33
startTransition ( ( ) => {
34
- if ( activeId != entry . target . id ) setActiveId ( entry . target . id ) ;
34
+ if ( activeId != entry . target . id ) {
35
+ setActiveId ( entry . target . id ) ;
36
+
37
+ const { state } = history ;
38
+ history . replaceState ( state , '' , `#${ entry . target . id } ` ) ;
39
+ }
35
40
} ) ;
36
41
}
37
42
} ) ;
@@ -106,6 +111,9 @@ export const TocTree = ({
106
111
const handle = ( ) => {
107
112
springScrollToElement ( $el , - 100 ) . then ( ( ) => {
108
113
setActiveId ?.( anchorId ) ;
114
+
115
+ const { state } = history ;
116
+ history . replaceState ( state , '' , `#${ anchorId } ` ) ;
109
117
} ) ;
110
118
} ;
111
119
You can’t perform that action at this time.
0 commit comments