Files
gastro-bot/src/app/[locale]/category/page.tsx
Samandar Turgunboyev 2535913eb2 complated order
2026-02-04 18:29:55 +05:00

94 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 dokonimizdagi kategoriyalar: ${categoryNames}`,
keywords: `kategoriyalar, mahsulotlar, dokon, ${categoryNames}`,
openGraph: {
title: 'Kategoriyalar | GASTRO',
description: `Bizning dokonimizdagi 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 dokonimizdagi kategoriyalar: ${categoryNames}`,
images: ['/logos/logo.png'],
},
};
}
const Page = () => {
return (
<Suspense>
<Category />
</Suspense>
);
};
export default Page;