25 lines
551 B
Plaintext
25 lines
551 B
Plaintext
---
|
|
import { posts, tags } from '@/helpers/schema';
|
|
import PostsLayout from '@/layouts/posts/PostsLayout.astro';
|
|
import options from '@/options';
|
|
|
|
const { num } = Astro.params;
|
|
|
|
if (!num) {
|
|
Astro.response.status = 500;
|
|
throw new Error('No such page num existed.');
|
|
}
|
|
|
|
const pageNum = Number.parseInt(num);
|
|
if (pageNum <= 1) {
|
|
return Astro.redirect('/');
|
|
}
|
|
|
|
const total = Math.ceil(posts.length / options.settings.pagination.posts);
|
|
if (pageNum > total) {
|
|
return Astro.redirect(`${total}`, 302);
|
|
}
|
|
---
|
|
|
|
<PostsLayout {posts} {pageNum} {tags} />
|