diff --git a/themes/fukasawa/components/Catalog.js b/themes/fukasawa/components/Catalog.js index cad8ce68..500fa909 100644 --- a/themes/fukasawa/components/Catalog.js +++ b/themes/fukasawa/components/Catalog.js @@ -1,6 +1,7 @@ import React, { useRef } from 'react' import throttle from 'lodash.throttle' import { uuidToId } from 'notion-utils' +import { useGlobal } from '@/lib/global' /** * 目录导航组件 @@ -9,10 +10,8 @@ import { uuidToId } from 'notion-utils' * @constructor */ const Catalog = ({ toc }) => { - // 无目录就直接返回空 - if (!toc || toc.length < 1) { - return <>> - } + const { locale } = useGlobal() + // 监听滚动事件 React.useEffect(() => { window.addEventListener('scroll', actionSectionScrollSpy) @@ -56,8 +55,13 @@ const Catalog = ({ toc }) => { tRef?.current?.scrollTo({ top: 28 * index, behavior: 'smooth' }) }, throttleMs)) + // 无目录就直接返回空 + if (!toc || toc.length < 1) { + return <>> + } + return