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' import BLOG from '@/blog.config'
export const LayoutCategory = (props) => { export const LayoutCategory = (props) => {
const { category, categories } = props const { category, categoryOptions } = props
return <LayoutBase currentCategory={category} {...props}> return <LayoutBase currentCategory={category} {...props}>
<StickyBar> <StickyBar>
<CategoryList currentCategory={category} categories={categories} /> <CategoryList currentCategory={category} categoryOptions={categoryOptions} />
</StickyBar> </StickyBar>
<div className='md:mt-8'> <div className='md:mt-8'>
{BLOG.POST_LIST_STYLE !== 'page' {BLOG.POST_LIST_STYLE !== 'page'

View File

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

View File

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

View File

@@ -3,13 +3,13 @@ import LayoutBase from './LayoutBase'
import TagItem from './components/TagItem' import TagItem from './components/TagItem'
export const LayoutTagIndex = (props) => { export const LayoutTagIndex = (props) => {
const { tags } = props const { tagOptions } = props
const { locale } = useGlobal() const { locale } = useGlobal()
return <LayoutBase {...props}> return <LayoutBase {...props}>
<div className='bg-white dark:bg-hexo-black-gray px-10 py-10 shadow h-full'> <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 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'> <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> return <div key={tag.name} className='p-2'><TagItem key={tag.name} tag={tag} /></div>
}) } }) }
</div> </div>

View File

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

View File

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