Skip to content

Commit ccf861b

Browse files
committed
next主题,分类标签数量设置
1 parent 2594104 commit ccf861b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

themes/next/components/CategoryGroup.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { siteConfig } from '@/lib/config'
12
import Link from 'next/link'
23

34
const CategoryGroup = ({ currentCategory, categories }) => {
4-
if (!categories) return <></>
5+
if (!categories || categories.length === 0) return <></>
6+
const categoryCount = siteConfig('PREVIEW_CATEGORY_COUNT')
7+
const categoryOptions = categories.slice(0, categoryCount)
58
return <>
69
<div id='category-list' className='dark:border-gray-600 flex flex-wrap'>
7-
{categories.map(category => {
10+
{categoryOptions.map(category => {
811
const selected = currentCategory === category.name
912
return (
1013
<Link

themes/next/components/TagGroups.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { siteConfig } from '@/lib/config'
12
import TagItemMini from './TagItemMini'
23

34
/**
@@ -8,11 +9,14 @@ import TagItemMini from './TagItemMini'
89
* @constructor
910
*/
1011
const TagGroups = ({ tags, currentTag }) => {
11-
if (!tags) return <></>
12+
if (!tags || tags.length === 0) return <></>
13+
14+
const tagsCount = siteConfig('PREVIEW_TAG_COUNT')
15+
const tagOptions = tags.slice(0, tagsCount)
1216
return (
1317
<div id='tags-group' className='dark:border-gray-600 w-66 space-y-2'>
1418
{
15-
tags.map(tag => {
19+
tagOptions.map(tag => {
1620
const selected = tag.name === currentTag
1721
return <TagItemMini key={tag.name} tag={tag} selected={selected} />
1822
})

0 commit comments

Comments
 (0)