mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { siteConfig } from '@/lib/config'
|
|
import { useGlobal } from '@/lib/global'
|
|
import BlogPostCard from './BlogPostCard'
|
|
import BlogPostListEmpty from './BlogPostListEmpty'
|
|
import PaginationNumber from './PaginationNumber'
|
|
|
|
/**
|
|
* 文章列表分页表格
|
|
* @param page 当前页
|
|
* @param posts 所有文章
|
|
* @param tags 所有标签
|
|
* @returns {JSX.Element}
|
|
* @constructor
|
|
*/
|
|
const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
|
|
const { NOTION_CONFIG } = useGlobal()
|
|
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
|
|
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
|
|
|
|
if (!posts || posts.length === 0) {
|
|
return <BlogPostListEmpty />
|
|
} else {
|
|
return (
|
|
<div>
|
|
{/* 文章列表 */}
|
|
<div
|
|
id='posts-wrapper'
|
|
className='flex flex-wrap lg:space-y-4 space-y-1'>
|
|
{posts?.map((post, index) => (
|
|
<BlogPostCard key={post.id} index={index} post={post} />
|
|
))}
|
|
</div>
|
|
<PaginationNumber page={page} totalPage={totalPage} />
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default BlogPostListPage
|