Skip to content

Commit a9d5800

Browse files
committed
fix: avoid error when theme does not have .nav-bar class
1 parent 348f19a commit a9d5800

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/client/app/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export function useRoute(): Route {
172172
}
173173

174174
function scrollTo(el: HTMLElement, hash: string, smooth = false) {
175-
const pageOffset = (document.querySelector('.nav-bar') as HTMLElement)
176-
.offsetHeight
175+
const nav = document.querySelector('.nav-bar')
176+
const pageOffset = nav ? (nav as HTMLElement).offsetHeight : 0
177177
const target = el.classList.contains('.header-anchor')
178178
? el
179179
: document.querySelector(decodeURIComponent(hash))

0 commit comments

Comments
 (0)