Skip to content

Commit

Permalink
next主题,分类标签数量设置
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jan 22, 2024
1 parent 2594104 commit ccf861b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions themes/next/components/CategoryGroup.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions themes/next/components/TagGroups.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { siteConfig } from '@/lib/config'
import TagItemMini from './TagItemMini'

/**
Expand All @@ -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} />
})
Expand Down

0 comments on commit ccf861b

Please sign in to comment.