Skip to content

Commit

Permalink
feat: allow for disabling of active hash on scroll (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
achendrick authored and ulivz committed May 24, 2018
1 parent 0570777 commit 4c09627
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/default-theme-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ sidebarDepth: 2
---
```

### Active Header Links

By default, the nested header links and the hash in the URL are updated as the user scrolls to view the different sections of the page. This behavior can be disabled with the following theme config:

``` js
module.exports = {
themeConfig: {
disableActiveHash: true, // boolean
}
}
```

### Sidebar Groups

You can divide sidebar links into multiple groups by using objects:
Expand Down
4 changes: 4 additions & 0 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export default {
this.setActiveHash()
}, 300),
setActiveHash () {
if (this.$site.themeConfig.disableActiveHash) {
return
}
const sidebarLinks = [].slice.call(document.querySelectorAll('.sidebar-link'))
const anchors = [].slice.call(document.querySelectorAll('.header-anchor'))
.filter(anchor => sidebarLinks.some(sidebarLink => sidebarLink.hash === anchor.hash))
Expand Down

0 comments on commit 4c09627

Please sign in to comment.