fix: avoid error when theme does not have .nav-bar class

pull/317/head
Evan You 4 years ago
parent 348f19a537
commit a9d580069f

@ -172,8 +172,8 @@ export function useRoute(): Route {
} }
function scrollTo(el: HTMLElement, hash: string, smooth = false) { function scrollTo(el: HTMLElement, hash: string, smooth = false) {
const pageOffset = (document.querySelector('.nav-bar') as HTMLElement) const nav = document.querySelector('.nav-bar')
.offsetHeight const pageOffset = nav ? (nav as HTMLElement).offsetHeight : 0
const target = el.classList.contains('.header-anchor') const target = el.classList.contains('.header-anchor')
? el ? el
: document.querySelector(decodeURIComponent(hash)) : document.querySelector(decodeURIComponent(hash))

Loading…
Cancel
Save