fix: handle async searchParams in blog pagination
### Issue:
Next.js 15 requires searchParams to be awaited as it's now a Promise.
**Error Message:**
"Route "/blog" used `searchParams.page`. `searchParams` is a Promise and must be unwrapped with `await`"
### Solution:
Updated `src/app/blog/page.tsx` to properly await searchParams before accessing its properties.
**Changes:**
- **BlogPage component** - Added `await searchParams` before accessing page property
- Used destructuring: `const { page } = await searchParams`
- Updated parseInt to use destructured `page` variable
### Result:
- Fixed runtime error when accessing pagination params
- Pagination now works correctly with async searchParams
- Blog list pages load successfully with `/blog?page=X`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a5d88a22b6
commit
987703c5e7
@ -34,8 +34,9 @@ type PageProps = {
|
||||
|
||||
export default async function BlogPage({ searchParams }: PageProps) {
|
||||
const posts = await getHomepagePosts()
|
||||
const { page } = await searchParams
|
||||
const postsPerPage = 10
|
||||
const currentPage = parseInt(searchParams.page || '1', 10)
|
||||
const currentPage = parseInt(page || '1', 10)
|
||||
const totalPages = Math.ceil(posts.length / postsPerPage)
|
||||
|
||||
if (currentPage < 1 || currentPage > totalPages) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user