File tree 1 file changed +12
-1
lines changed
src/client/theme-default/composables
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ export function usePrevNext() {
8
8
9
9
return computed ( ( ) => {
10
10
const sidebar = getSidebar ( theme . value . sidebar , page . value . relativePath )
11
- const candidates = getFlatSideBarLinks ( sidebar )
11
+ const links = getFlatSideBarLinks ( sidebar )
12
+
13
+ // ignore inner-page links with hashes
14
+ const candidates = uniqBy ( links , ( link ) => link . link . replace ( / [ ? # ] .* $ / , '' ) )
12
15
13
16
const index = candidates . findIndex ( ( link ) => {
14
17
return isActive ( page . value . relativePath , link . link )
@@ -61,3 +64,11 @@ export function usePrevNext() {
61
64
}
62
65
} )
63
66
}
67
+
68
+ function uniqBy < T > ( array : T [ ] , keyFn : ( item : T ) => any ) : T [ ] {
69
+ const seen = new Set ( )
70
+ return array . filter ( ( item ) => {
71
+ const k = keyFn ( item )
72
+ return seen . has ( k ) ? false : seen . add ( k )
73
+ } )
74
+ }
You can’t perform that action at this time.
0 commit comments