This commit is contained in:
tangly1024.com
2023-02-03 14:03:36 +08:00
parent 80f4656021
commit 94a0d0eabd
6 changed files with 19 additions and 19 deletions

View File

@@ -6,10 +6,10 @@ import BlogPostListPage from './components/BlogPostListPage'
import BLOG from '@/blog.config'
export const LayoutCategory = (props) => {
const { category, categories } = props
const { category, categoryOptions } = props
return <LayoutBase currentCategory={category} {...props}>
<StickyBar>
<CategoryList currentCategory={category} categories={categories} />
<CategoryList currentCategory={category} categoryOptions={categoryOptions} />
</StickyBar>
<div className='md:mt-8'>
{BLOG.POST_LIST_STYLE !== 'page'

View File

@@ -3,7 +3,7 @@ import LayoutBase from './LayoutBase'
import Link from 'next/link'
export const LayoutCategoryIndex = (props) => {
const { allPosts, categories } = props
const { allPosts, categoryOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase totalPosts={allPosts} {...props}>
@@ -12,7 +12,7 @@ export const LayoutCategoryIndex = (props) => {
<i className='mr-4 fas faTh' />{locale.COMMON.CATEGORY}:
</div>
<div id='category-list' className='duration-200 flex flex-wrap'>
{categories.map(category => {
{categoryOptions.map(category => {
return (
<Link
key={category.name}
@@ -24,10 +24,10 @@ export const LayoutCategoryIndex = (props) => {
<i className='mr-4 fas fa-folder' />{category.name}({category.count})
</div>
</Link>
);
)
})}
</div>
</div>
</LayoutBase>
);
)
}

View File

@@ -6,11 +6,11 @@ import BlogPostListPage from './components/BlogPostListPage'
import BLOG from '@/blog.config'
export const LayoutTag = (props) => {
const { tags, tag } = props
const { tagOptions, tag } = props
return <LayoutBase currentTag={tag} {...props}>
<StickyBar>
<TagList tags={tags} currentTag={tag} />
<TagList tagOptions={tagOptions} currentTag={tag} />
</StickyBar>
<div className='md:mt-8'>
{BLOG.POST_LIST_STYLE !== 'page'

View File

@@ -3,13 +3,13 @@ import LayoutBase from './LayoutBase'
import TagItem from './components/TagItem'
export const LayoutTagIndex = (props) => {
const { tags } = props
const { tagOptions } = props
const { locale } = useGlobal()
return <LayoutBase {...props}>
<div className='bg-white dark:bg-hexo-black-gray px-10 py-10 shadow h-full'>
<div className='dark:text-gray-200 mb-5'><i className='fas fa-tags mr-4'/>{locale.COMMON.TAGS}:</div>
<div id='tags-list' className='duration-200 flex flex-wrap'>
{ tags.map(tag => {
{ tagOptions.map(tag => {
return <div key={tag.name} className='p-2'><TagItem key={tag.name} tag={tag} /></div>
}) }
</div>

View File

@@ -2,16 +2,16 @@ import Link from 'next/link'
import React from 'react'
import { useGlobal } from '@/lib/global'
const CategoryList = ({ currentCategory, categories }) => {
if (!categories) {
const CategoryList = ({ currentCategory, categoryOptions }) => {
const { locale } = useGlobal()
if (!categoryOptions) {
return <></>
}
const { locale } = useGlobal()
return (
<ul className='flex py-1 space-x-3'>
<li className='w-16 py-2 dark:text-gray-200 whitespace-nowrap'>{locale.COMMON.CATEGORY}</li>
{categories.map(category => {
{categoryOptions.map(category => {
const selected = category.name === currentCategory
return (
<Link
@@ -32,10 +32,10 @@ const CategoryList = ({ currentCategory, categories }) => {
</a>
</li>
</Link>
);
)
})}
</ul>
);
)
}
export default CategoryList

View File

@@ -7,13 +7,13 @@ import TagItem from './TagItem'
* @returns {JSX.Element}
* @constructor
*/
const TagList = ({ tags, currentTag }) => {
if (!tags) {
const TagList = ({ tagOptions, currentTag }) => {
if (!tagOptions) {
return <></>
}
return <ul className='flex py-1 space-x-3'>
<li className='w-20 py-2 dark:text-gray-200 whitespace-nowrap'>标签:</li>
{tags.map(tag => {
{tagOptions.map(tag => {
const selected = tag.name === currentTag
return <TagItem key={tag.name} tag={tag} selected={selected}/>
})}