mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
bugfix:
所有标签页数量修复
This commit is contained in:
@@ -30,7 +30,7 @@ export async function getAllTags ({ allPosts, sliceCount = 12, tagOptions }) {
|
||||
return { name: tag, count: tagObj[tag], color }
|
||||
})
|
||||
list.sort((a, b) => b.count - a.count)
|
||||
if (sliceCount) {
|
||||
if (sliceCount && sliceCount > 0) {
|
||||
return list.slice(0, 12)
|
||||
} else {
|
||||
return list
|
||||
|
||||
@@ -2,17 +2,20 @@ import { getAllCategories, getAllPosts, getAllTags } from '@/lib/notion'
|
||||
import BLOG from '@/blog.config'
|
||||
import BaseLayout from '@/layouts/BaseLayout'
|
||||
import TagItem from '@/components/TagItem'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
export default function Tag ({ tags, posts, categories }) {
|
||||
export default function Tag ({ tags, allPosts, categories }) {
|
||||
const meta = {
|
||||
title: `${BLOG.title} | 标签`,
|
||||
description: BLOG.description,
|
||||
type: 'website'
|
||||
}
|
||||
return <BaseLayout meta={meta} categories={categories} totalPosts={posts}>
|
||||
const { locale } = useGlobal()
|
||||
return <BaseLayout meta={meta} categories={categories} totalPosts={allPosts}>
|
||||
<div className='flex-grow bg-gray-200 dark:bg-black shadow-inner p-10'>
|
||||
<div className='bg-white dark:bg-gray-700 px-10 py-5 mt-20'>
|
||||
<div className='dark:text-gray-200 my-5'>所有标签:</div>
|
||||
<div className='dark:text-gray-200 my-5'>{locale.COMMON.TAGS}:</div>
|
||||
<div id='tags-list' className='duration-200 flex flex-wrap'>
|
||||
{
|
||||
tags.map(tag => {
|
||||
@@ -26,16 +29,16 @@ export default function Tag ({ tags, posts, categories }) {
|
||||
}
|
||||
|
||||
export async function getStaticProps () {
|
||||
let posts = await getAllPosts({ from: 'tag-props' })
|
||||
posts = posts.filter(
|
||||
post => post.status[0] === 'Published' && post.type[0] === 'Post'
|
||||
)
|
||||
const tags = await getAllTags(posts, 0)
|
||||
const categories = await getAllCategories(posts)
|
||||
const from = 'tag-index-props'
|
||||
const notionPageData = await getNotionPageData({ from })
|
||||
const allPosts = await getAllPosts({ notionPageData, from })
|
||||
const categories = await getAllCategories(allPosts)
|
||||
const tagOptions = notionPageData.tagOptions
|
||||
const tags = await getAllTags({ allPosts, sliceCount: 0, tagOptions })
|
||||
return {
|
||||
props: {
|
||||
tags,
|
||||
posts,
|
||||
allPosts,
|
||||
categories
|
||||
},
|
||||
revalidate: 1
|
||||
|
||||
Reference in New Issue
Block a user