Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow for disabling of active hash on scroll (#482) #489

Merged
merged 1 commit into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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