From 560c19a7e120dfb33e3a20f57a3537711a93d324 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sat, 23 Nov 2024 12:28:09 +0800 Subject: [PATCH] fix jump --- components/NotionPage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 5bc3c31a..0ac8c1c0 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -149,9 +149,11 @@ const processGalleryImg = zoom => { const autoScrollToHash = () => { setTimeout(() => { // 跳转到指定标题 - const needToJumpToTitle = window.location.hash + const hash = window?.location?.hash + const needToJumpToTitle = hash && hash > 0 if (needToJumpToTitle) { - const tocNode = document.getElementById(window.location.hash.substring(1)) + console.log('jump to hash', hash) + const tocNode = document.getElementById(hash.substring(1)) if (tocNode && tocNode?.className?.indexOf('notion') > -1) { tocNode.scrollIntoView({ block: 'start', behavior: 'smooth' }) }