Skip to content

Commit

Permalink
fix: avoid error when theme does not have .nav-bar class
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 15, 2021
1 parent 348f19a commit a9d5800
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export function useRoute(): Route {
}

function scrollTo(el: HTMLElement, hash: string, smooth = false) {
const pageOffset = (document.querySelector('.nav-bar') as HTMLElement)
.offsetHeight
const nav = document.querySelector('.nav-bar')
const pageOffset = nav ? (nav as HTMLElement).offsetHeight : 0
const target = el.classList.contains('.header-anchor')
? el
: document.querySelector(decodeURIComponent(hash))
Expand Down

0 comments on commit a9d5800

Please sign in to comment.