wip
This commit is contained in:
@@ -1,31 +1,22 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
import { getAllCategories, getProductsByCategory } from '@/lib/data'
|
||||
import { getAllCategories, getProductsByCategorySlugWithExcel } from '@/lib/data'
|
||||
import { ProductList } from '@/components/ProductList'
|
||||
import { Metadata } from 'next'
|
||||
import { ContentRenderer } from '@/components/content/ContentRenderer'
|
||||
|
||||
interface PageProps {
|
||||
params: {
|
||||
locale: string
|
||||
slug: string
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const categories = getAllCategories()
|
||||
return categories.map((category) => ({
|
||||
locale: 'de', // Default locale
|
||||
slug: category.slug
|
||||
}))
|
||||
slug: string;
|
||||
locale: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const categories = getAllCategories()
|
||||
const category = categories.find((cat) => cat.slug === params.slug)
|
||||
|
||||
const category = categories.find(c => c.slug === params.slug && c.locale === params.locale)
|
||||
|
||||
if (!category) {
|
||||
return {
|
||||
title: 'Category Not Found'
|
||||
title: 'Category not found',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,26 +28,24 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
|
||||
|
||||
export default async function ProductCategoryPage({ params }: PageProps) {
|
||||
const categories = getAllCategories()
|
||||
const category = categories.find((cat) => cat.slug === params.slug)
|
||||
const category = categories.find(c => c.slug === params.slug && c.locale === params.locale)
|
||||
|
||||
if (!category) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const products = getProductsByCategory(category.id, params.locale)
|
||||
const products = getProductsByCategorySlugWithExcel(params.slug, params.locale)
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<h1 className="text-4xl font-bold mb-6">{category.name}</h1>
|
||||
{category.description && (
|
||||
<ContentRenderer
|
||||
content={category.description}
|
||||
className="mb-8 prose max-w-none"
|
||||
/>
|
||||
)}
|
||||
<h1 className="text-4xl font-bold mb-8">{category.name}</h1>
|
||||
|
||||
{category.description && (
|
||||
<p className="text-gray-600 mb-8 text-lg">{category.description}</p>
|
||||
)}
|
||||
|
||||
{products.length > 0 ? (
|
||||
<ProductList products={products} />
|
||||
<ProductList products={products} locale={params.locale as 'en' | 'de'} />
|
||||
) : (
|
||||
<p className="text-gray-500">No products found in this category.</p>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user