auto-claude: subtask-1-4 - Add URL state management using searchParams and router.push
This commit is contained in:
@@ -7,6 +7,7 @@ import { BlogList } from '@/components/blog/BlogList';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ locale: string }>;
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
};
|
||||
|
||||
// Legacy blog posts with translations (these have manual translations)
|
||||
@@ -304,8 +305,9 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
}
|
||||
|
||||
|
||||
export default async function BlogPage({ params }: Props) {
|
||||
export default async function BlogPage({ params, searchParams }: Props) {
|
||||
const { locale } = await params;
|
||||
const resolvedSearchParams = await searchParams;
|
||||
setRequestLocale(locale);
|
||||
|
||||
const t = await getTranslations('blog');
|
||||
@@ -323,6 +325,10 @@ export default async function BlogPage({ params }: Props) {
|
||||
...legacyPosts,
|
||||
].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||
|
||||
// Extract search and category from URL params
|
||||
const initialSearch = typeof resolvedSearchParams.search === 'string' ? resolvedSearchParams.search : '';
|
||||
const initialCategory = typeof resolvedSearchParams.category === 'string' ? resolvedSearchParams.category : null;
|
||||
|
||||
return (
|
||||
<main className="min-h-screen">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16 sm:py-20 lg:py-24">
|
||||
@@ -344,6 +350,8 @@ export default async function BlogPage({ params }: Props) {
|
||||
<BlogList
|
||||
posts={allPosts}
|
||||
locale={locale}
|
||||
initialSearch={initialSearch}
|
||||
initialCategory={initialCategory}
|
||||
translations={{
|
||||
searchPlaceholder: t('ui.search.placeholder'),
|
||||
showingText: (start: number, end: number, total: number) =>
|
||||
|
||||
Reference in New Issue
Block a user