next主题,分类标签数量设置

This commit is contained in:
tangly1024
2024-01-22 21:00:12 +08:00
parent 259410480f
commit ccf861bb67
2 changed files with 11 additions and 4 deletions

View File

@@ -1,10 +1,13 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) return <></>
if (!categories || categories.length === 0) return <></>
const categoryCount = siteConfig('PREVIEW_CATEGORY_COUNT')
const categoryOptions = categories.slice(0, categoryCount)
return <>
<div id='category-list' className='dark:border-gray-600 flex flex-wrap'>
{categories.map(category => {
{categoryOptions.map(category => {
const selected = currentCategory === category.name
return (
<Link

View File

@@ -1,3 +1,4 @@
import { siteConfig } from '@/lib/config'
import TagItemMini from './TagItemMini'
/**
@@ -8,11 +9,14 @@ import TagItemMini from './TagItemMini'
* @constructor
*/
const TagGroups = ({ tags, currentTag }) => {
if (!tags) return <></>
if (!tags || tags.length === 0) return <></>
const tagsCount = siteConfig('PREVIEW_TAG_COUNT')
const tagOptions = tags.slice(0, tagsCount)
return (
<div id='tags-group' className='dark:border-gray-600 w-66 space-y-2'>
{
tags.map(tag => {
tagOptions.map(tag => {
const selected = tag.name === currentTag
return <TagItemMini key={tag.name} tag={tag} selected={selected} />
})