import type { Metadata } from 'next';
import DatacenterPageClient from './DatacenterPageClient';
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.datacenter;

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

    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,
        },
        alternates: {
            canonical: currentUrl,
            languages: {
                zh: `${baseUrl}/zh/datacenter`,
                'zh-CN': `${baseUrl}/zh/datacenter`,
                'zh-TW': `${baseUrl}/tw/datacenter`,
                'zh-HK': `${baseUrl}/tw/datacenter`,
                en: `${baseUrl}/en/datacenter`,
            },
        },
    };
}

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