diff --git a/themes/next/components/Toc.js b/themes/next/components/Toc.js index 5dbbad5f..6d98ee4a 100644 --- a/themes/next/components/Toc.js +++ b/themes/next/components/Toc.js @@ -11,10 +11,6 @@ import Progress from './Progress' * @constructor */ const Toc = ({ toc }) => { - // 无目录就直接返回空 - if (!toc || toc.length < 1) { - return <> - } // 监听滚动事件 React.useEffect(() => { window.addEventListener('scroll', actionSectionScrollSpy) @@ -58,6 +54,11 @@ const Toc = ({ toc }) => { tRef?.current?.scrollTo({ top: 28 * index, behavior: 'smooth' }) }, throttleMs)) + // 无目录就直接返回空 + if (!toc || toc.length < 1) { + return <> + } + return