diff --git a/components/Comment.js b/components/Comment.js index 4bae2665..20e1b119 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -2,6 +2,7 @@ import BLOG from '@/blog.config' import dynamic from 'next/dynamic' import Tabs from '@/components/Tabs' import { useGlobal } from '@/lib/global' +import React from 'react' const WalineComponent = dynamic( () => { @@ -46,6 +47,16 @@ const Comment = ({ frontMatter }) => { } const { isDarkMode } = useGlobal() + // 需要跳转到评论区域 + React.useEffect(() => { + setTimeout(() => { + if (window.location.hash) { + const commentNode = document.getElementById('comment') + commentNode.scrollIntoView({ block: 'start', behavior: 'smooth' }) + } + }, 200) + }, []) + return (