From a7d901ac17d0f4c3aa16d9e71afc9493add8e7cd Mon Sep 17 00:00:00 2001
From: ShH Y <74806550+1208nn@users.noreply.github.com>
Date: Sat, 20 Jan 2024 21:12:53 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=9A=90=E8=97=8F?=
=?UTF-8?q?=E5=8D=95=E7=8B=AC=E7=9A=84=E8=AF=84=E8=AE=BA=E6=A0=87=E7=AD=BE?=
=?UTF-8?q?=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blog.config.js | 2 ++
components/Tabs.js | 20 +++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/blog.config.js b/blog.config.js
index 699e0962..d0b99cc8 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -239,6 +239,8 @@ const BLOG = {
// ********挂件组件相关********
// ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK
+ COMMENT_HIDE_SINGLE_TAB: process.env.NEXT_PUBLIC_COMMENT_HIDE_SINGLE_TAB || false, //Whether hide the tab when there's no tabs. 只有一个评论组件时是否隐藏切换组件的标签页
+
// artalk 评论插件
COMMENT_ARTALK_SERVER: process.env.NEXT_PUBLIC_COMMENT_ARTALK_SERVER || '', // ArtalkServert后端地址 https://artalk.js.org/guide/deploy.html
COMMENT_ARTALK_JS: process.env.NEXT_PUBLIC_COMMENT_ARTALK_JS || 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.js', // ArtalkServert js cdn
diff --git a/components/Tabs.js b/components/Tabs.js
index eb1e2e69..08b86099 100644
--- a/components/Tabs.js
+++ b/components/Tabs.js
@@ -16,15 +16,17 @@ const Tabs = ({ className, children }) => {
return (
-
- {validChildren.map((item, index) => (
- - setCurrentTab(index)}>
- {item.key}
-
- ))}
-
+ {(validChildren.length === 1 && siteConfig('COMMENT_HIDE_SINGLE_TAB')) && (
+
+ {validChildren.map((item, index) => (
+ - setCurrentTab(index)}>
+ {item.key}
+
+ ))}
+
+ )}
{/* 标签切换的时候不销毁 DOM 元素,使用 CSS 样式进行隐藏 */}
{validChildren.map((item, index) => (
From 94d90890c54bc4ffdf47cc72ac91e3a46b562d27 Mon Sep 17 00:00:00 2001
From: ShH Y <74806550+1208nn@users.noreply.github.com>
Date: Sat, 20 Jan 2024 21:18:31 +0800
Subject: [PATCH 2/3] fix dependency
---
components/Tabs.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/components/Tabs.js b/components/Tabs.js
index 08b86099..acebf7e5 100644
--- a/components/Tabs.js
+++ b/components/Tabs.js
@@ -1,4 +1,5 @@
import { useState } from 'react';
+import { siteConfig } from '@/lib/config'
/**
* Tabs切换标签
From 55e6619113b4554323913726a5671406648dd6b2 Mon Sep 17 00:00:00 2001
From: ShH Y <74806550+1208nn@users.noreply.github.com>
Date: Sat, 20 Jan 2024 21:38:50 +0800
Subject: [PATCH 3/3] =?UTF-8?q?fix=20=E5=8F=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/Tabs.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/Tabs.js b/components/Tabs.js
index acebf7e5..37766c24 100644
--- a/components/Tabs.js
+++ b/components/Tabs.js
@@ -17,7 +17,7 @@ const Tabs = ({ className, children }) => {
return (
- {(validChildren.length === 1 && siteConfig('COMMENT_HIDE_SINGLE_TAB')) && (
+ {!(validChildren.length === 1 && siteConfig('COMMENT_HIDE_SINGLE_TAB')) && (
{validChildren.map((item, index) => (