import type { Metadata } from 'next';
import ProductsPageClient from './ProductsPageClient';
import { getTranslations, type Language } from '@/lib/languages';

export async function generateMetadata({
    params,
}: {
    params: { lang: string };
}): Promise<Metadata> {
    const lang = params.lang as Language;
    const t = getTranslations(lang);
    const seoData = t.seo.products;

    const baseUrl = 'https://cybercloud.com';
    const currentUrl = `${baseUrl}/${lang}/products`;

    return {
        title: seoData.title,
        description: seoData.description,
        keywords: seoData.keywords,
        openGraph: {
            type: 'website',
            locale: lang === 'zh' ? 'zh_CN' : lang === 'tw' ? 'zh_TW' : 'en_US',
            url: currentUrl,
            siteName: 'CyberCloud',
            title: seoData.title,
            description: seoData.description,
            images: [
                {
                    url: `${baseUrl}/images/products-og-${lang}.jpg`,
                    width: 1200,
                    height: 630,
                    alt: t.pages.products.title,
                },
            ],
        },
        alternates: {
            canonical: currentUrl,
            languages: {
                zh: `${baseUrl}/zh/products`,
                'zh-CN': `${baseUrl}/zh/products`,
                'zh-TW': `${baseUrl}/tw/products`,
                'zh-HK': `${baseUrl}/tw/products`,
                en: `${baseUrl}/en/products`,
            },
        },
    };
}

export default function ProductsPage({ params }: { params: { lang: string } }) {
    return <ProductsPageClient params={params} />;
}
