修复部分NOTION_CONFIG读取问题

This commit is contained in:
tangly1024.com
2024-05-15 14:55:14 +08:00
parent 70e53649b3
commit 517a967640
44 changed files with 911 additions and 565 deletions

View File

@@ -1,7 +1,8 @@
import ProductCard from './ProductCard'
import PaginationNumber from './PaginationNumber'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import BlogPostListEmpty from './BlogPostListEmpty'
import PaginationNumber from './PaginationNumber'
import ProductCard from './ProductCard'
/**
* 文章列表分页表格
@@ -12,20 +13,29 @@ import BlogPostListEmpty from './BlogPostListEmpty'
* @constructor
*/
const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const totalPage = Math.ceil(postCount / parseInt(siteConfig('POSTS_PER_PAGE')))
const showPagination = postCount >= parseInt(siteConfig('POSTS_PER_PAGE'))
const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPagination = postCount >= POSTS_PER_PAGE
if (!posts || posts.length === 0 || page > totalPage) {
return <BlogPostListEmpty />
} else {
return (
<div id="container" className='w-full'>
<div id='container' className='w-full'>
{/* 文章列表 */}
<div className="py-4 gap-4 grid grid-cols-3">
<div className='py-4 gap-4 grid grid-cols-3'>
{posts?.map(post => (
<ProductCard index={posts.indexOf(post)} key={post.id} post={post} siteInfo={siteInfo}/>
<ProductCard
index={posts.indexOf(post)}
key={post.id}
post={post}
siteInfo={siteInfo}
/>
))}
</div>
{showPagination && <PaginationNumber page={page} totalPage={totalPage} />}
{showPagination && (
<PaginationNumber page={page} totalPage={totalPage} />
)}
</div>
)
}