2024-06-14 02:11:26 +08:00
|
|
|
---
|
2024-06-21 00:17:18 +08:00
|
|
|
import Pagination from '@/components/page/pagination/Pagination.astro';
|
|
|
|
import { slicePosts } from '@/helpers/formatter';
|
2024-06-14 02:11:26 +08:00
|
|
|
import type { Post } from '@/helpers/schema';
|
2024-06-21 00:17:18 +08:00
|
|
|
import options from '@/options';
|
|
|
|
import PostCard from './PostCard.astro';
|
2024-06-14 02:11:26 +08:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
posts: Post[];
|
2024-06-21 00:17:18 +08:00
|
|
|
pageNum: number;
|
2024-06-14 02:11:26 +08:00
|
|
|
}
|
|
|
|
|
2024-06-21 00:17:18 +08:00
|
|
|
const { pageNum, posts } = Astro.props;
|
|
|
|
const results = slicePosts(posts, pageNum, options.settings.pagination.posts);
|
|
|
|
if (!results) {
|
|
|
|
return Astro.redirect('/404');
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentPosts, totalPage } = results;
|
2024-06-14 02:11:26 +08:00
|
|
|
---
|
|
|
|
|
2024-06-21 00:17:18 +08:00
|
|
|
<div class="content-wrapper content-wrapper col-12 col-xl-9">
|
|
|
|
<div class="list-grid">{currentPosts.map((post) => <PostCard post={post} />)}</div>
|
|
|
|
<Pagination current={pageNum} total={totalPage} rootPath={'/'} />
|
|
|
|
</div>
|