From 79dcb0d78ad1f6fb7b3260b9986f8b2c8c8c1ee3 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 20 Jan 2023 13:29:52 +0800 Subject: [PATCH] multi language catalog --- themes/fukasawa/components/Catalog.js | 14 +++++++++----- themes/hexo/components/Catalog.js | 4 +++- themes/matery/components/Catalog.js | 4 +++- 3 files changed, 15 insertions(+), 7 deletions(-) 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
-
目录
+
{locale.COMMON.TABLE_OF_CONTENTS}