diff --git a/src/components/blog/TOCHeading.astro b/src/components/blog/TOCHeading.astro index fe50269..79ca19a 100644 --- a/src/components/blog/TOCHeading.astro +++ b/src/components/blog/TOCHeading.astro @@ -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' }) + } } }) })