File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
const { path } = require ( '@vuepress/shared-utils' )
2
2
3
- module . exports = {
4
- clientRootMixin : path . resolve ( __dirname , 'mixin.js' )
5
- }
3
+ module . exports = ( options ) => ( {
4
+ clientRootMixin : path . resolve ( __dirname , 'mixin.js' ) ,
5
+ define : {
6
+ AHL_SIDEBAR_LINK_SELECTOR : options . sidebarLinkSelector || '.sidebar-link' ,
7
+ AHL_HEADER_ANCHOR_SELECTOR : options . headerAnchorSelector || '.header-anchor'
8
+ }
9
+ } )
Original file line number Diff line number Diff line change
1
+ /* global AHL_SIDEBAR_LINK_SELECTOR, AHL_HEADER_ANCHOR_SELECTOR */
2
+
1
3
import throttle from 'lodash.throttle'
2
4
3
5
function calculateCurrentAnchor ( anchors ) {
@@ -25,9 +27,9 @@ function calculateCurrentAnchor (anchors) {
25
27
}
26
28
27
29
function getAnchors ( ) {
28
- const sidebarLinks = [ ] . slice . call ( document . querySelectorAll ( '.sidebar-link' ) )
30
+ const sidebarLinks = [ ] . slice . call ( document . querySelectorAll ( AHL_SIDEBAR_LINK_SELECTOR ) )
29
31
return [ ] . slice
30
- . call ( document . querySelectorAll ( '.header-anchor' ) )
32
+ . call ( document . querySelectorAll ( AHL_HEADER_ANCHOR_SELECTOR ) )
31
33
. filter ( anchor => sidebarLinks . some ( sidebarLink => sidebarLink . hash === anchor . hash ) )
32
34
. map ( el => {
33
35
return {
You can’t perform that action at this time.
0 commit comments