diff options
Diffstat (limited to 'src/app/(main)/(home)/posts')
| -rw-r--r-- | src/app/(main)/(home)/posts/page.tsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/app/(main)/(home)/posts/page.tsx b/src/app/(main)/(home)/posts/page.tsx index daced35..376f5c1 100644 --- a/src/app/(main)/(home)/posts/page.tsx +++ b/src/app/(main)/(home)/posts/page.tsx @@ -55,16 +55,18 @@ export default async function Page(props: { }) { const searchParams = await props.searchParams; - const pageIndex = searchParams.page + const rawPage = searchParams.page ? Number.parseInt( Array.isArray(searchParams.page) ? (searchParams.page[0] ?? '') : searchParams.page, 10, - ) - 1 - : 0; + ) + : 1; + + if (Number.isNaN(rawPage)) notFound(); - if (Number.isNaN(pageIndex)) notFound(); + const pageIndex = rawPage - 1; // 获取文章(带分页) const { posts, totalDocs, totalPages } = await getPublishedPosts({ |
