94 lines
2.4 KiB
TypeScript
94 lines
2.4 KiB
TypeScript
// app/category/page.tsx
|
||
import Category from '@/features/category/ui/Category';
|
||
import { category_api } from '@/shared/config/api/category/api';
|
||
import { Metadata } from 'next';
|
||
import { Suspense } from 'react';
|
||
|
||
const fetchCategoryData = async () => {
|
||
try {
|
||
const res = await category_api.getCategory({ page: 1, page_size: 99 });
|
||
return res.data;
|
||
} catch {
|
||
return [];
|
||
}
|
||
};
|
||
|
||
interface PageProps {
|
||
params: {
|
||
locale: 'uz' | 'ru';
|
||
};
|
||
}
|
||
|
||
export async function generateMetadata({
|
||
params,
|
||
}: PageProps): Promise<Metadata> {
|
||
const { locale } = await params;
|
||
const categories = await fetchCategoryData();
|
||
const categoryNames = categories.map((c) => c.name).join(', ');
|
||
|
||
if (locale === 'ru') {
|
||
return {
|
||
title: 'Категории | GASTRO',
|
||
description: `Категории в нашем магазине: ${categoryNames}`,
|
||
keywords: `категории, продукты, магазин, ${categoryNames}`,
|
||
openGraph: {
|
||
title: 'Категории | GASTRO',
|
||
description: `Категории в нашем магазине: ${categoryNames}`,
|
||
siteName: 'GASTRO',
|
||
images: [
|
||
{
|
||
url: '/logos/logo.png',
|
||
width: 1200,
|
||
height: 1200,
|
||
alt: 'Категории',
|
||
},
|
||
],
|
||
type: 'website',
|
||
},
|
||
twitter: {
|
||
card: 'summary_large_image',
|
||
title: 'Категории | GASTRO',
|
||
description: `Категории в нашем магазине: ${categoryNames}`,
|
||
images: ['/logos/logo.png'],
|
||
},
|
||
};
|
||
}
|
||
|
||
// default: Uzbek
|
||
return {
|
||
title: 'Kategoriyalar | GASTRO',
|
||
description: `Bizning do‘konimizdagi kategoriyalar: ${categoryNames}`,
|
||
keywords: `kategoriyalar, mahsulotlar, do‘kon, ${categoryNames}`,
|
||
openGraph: {
|
||
title: 'Kategoriyalar | GASTRO',
|
||
description: `Bizning do‘konimizdagi kategoriyalar: ${categoryNames}`,
|
||
siteName: 'GASTRO',
|
||
images: [
|
||
{
|
||
url: '/logos/logo.png',
|
||
width: 1200,
|
||
height: 1200,
|
||
alt: 'Kategoriyalar',
|
||
},
|
||
],
|
||
type: 'website',
|
||
},
|
||
twitter: {
|
||
card: 'summary_large_image',
|
||
title: 'Kategoriyalar | GASTRO',
|
||
description: `Bizning do‘konimizdagi kategoriyalar: ${categoryNames}`,
|
||
images: ['/logos/logo.png'],
|
||
},
|
||
};
|
||
}
|
||
|
||
const Page = () => {
|
||
return (
|
||
<Suspense>
|
||
<Category />
|
||
</Suspense>
|
||
);
|
||
};
|
||
|
||
export default Page;
|