Skip to content

Commit c22084e

Browse files
authored
Merge pull request #1787 from 1208nn/dev
支持隐藏单独的评论标签页
2 parents f88bb00 + 55e6619 commit c22084e

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Diff for: blog.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ const BLOG = {
244244
// ********挂件组件相关********
245245
// ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK
246246

247+
COMMENT_HIDE_SINGLE_TAB: process.env.NEXT_PUBLIC_COMMENT_HIDE_SINGLE_TAB || false, //Whether hide the tab when there's no tabs. 只有一个评论组件时是否隐藏切换组件的标签页
248+
247249
// artalk 评论插件
248250
COMMENT_ARTALK_SERVER: process.env.NEXT_PUBLIC_COMMENT_ARTALK_SERVER || '', // ArtalkServert后端地址 https://artalk.js.org/guide/deploy.html
249251
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 for: components/Tabs.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react';
2+
import { siteConfig } from '@/lib/config'
23

34
/**
45
* Tabs切换标签
@@ -16,15 +17,17 @@ const Tabs = ({ className, children }) => {
1617

1718
return (
1819
<div className={`mb-5 duration-200 ${className}`}>
19-
<ul className="flex justify-center space-x-5 pb-4 dark:text-gray-400 text-gray-600 overflow-auto">
20-
{validChildren.map((item, index) => (
21-
<li key={index}
22-
className={`${currentTab === index ? 'font-black border-b-2 border-red-600 text-red-600 animate__animated animate__jello' : 'font-extralight cursor-pointer'} text-sm font-sans`}
23-
onClick={() => setCurrentTab(index)}>
24-
{item.key}
25-
</li>
26-
))}
27-
</ul>
20+
{!(validChildren.length === 1 && siteConfig('COMMENT_HIDE_SINGLE_TAB')) && (
21+
<ul className="flex justify-center space-x-5 pb-4 dark:text-gray-400 text-gray-600 overflow-auto">
22+
{validChildren.map((item, index) => (
23+
<li key={index}
24+
className={`${currentTab === index ? 'font-black border-b-2 border-red-600 text-red-600 animate__animated animate__jello' : 'font-extralight cursor-pointer'} text-sm font-sans`}
25+
onClick={() => setCurrentTab(index)}>
26+
{item.key}
27+
</li>
28+
))}
29+
</ul>
30+
)}
2831
{/* 标签切换的时候不销毁 DOM 元素,使用 CSS 样式进行隐藏 */}
2932
<div>
3033
{validChildren.map((item, index) => (

0 commit comments

Comments
 (0)