fix: add toc slug judge

This commit is contained in:
KazooTTT
2024-10-15 12:51:58 +08:00
parent f2a7ecc339
commit 3194617e79

View File

@ -35,9 +35,11 @@ const {
link.addEventListener('click', (event) => {
event.preventDefault()
const slug = link.getAttribute('data-slug')
const element = document.getElementById(slug)
if (element) {
element.scrollIntoView({ behavior: 'smooth' })
if (slug) {
const element = document.getElementById(slug)
if (element) {
element.scrollIntoView({ behavior: 'smooth' })
}
}
})
})