fix: add force-dynamic directive to blog page for searchParams support

### Issue:
The root layout has `export const dynamic = 'error'` which forces static rendering.
The blog page uses `searchParams` which requires dynamic rendering.

**Error Message:**
"Route /blog with `dynamic = "error"` couldn't be rendered statically because it used `searchParams`"

### Solution:
Added `export const dynamic = 'force-dynamic'` to `src/app/blog/page.tsx` to override
the parent's static rendering directive and enable dynamic rendering for searchParams.

### Changes:
- **BlogPage** - Added `export const dynamic = 'force-dynamic'` at the top of the file
- This allows the page to use `searchParams` for pagination
- Page will be dynamically rendered on each request with the correct page data

### Result:
- Fixed runtime error when accessing pagination params
- Blog list pages load successfully with `/blog?page=X`
- Pagination works correctly with dynamic searchParams
- Build passes successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Haitao Pan 2025-11-11 13:46:03 +08:00
parent 987703c5e7
commit fff6816077

View File

@ -1,3 +1,5 @@
export const dynamic = 'force-dynamic'
import Link from 'next/link'
import { getHomepagePosts } from '@cms/content'
import type { Metadata } from 'next'