import { getTranslations, getNavigationPaths } from '@/lib/i18n';
import { generateMetadata as generateSEOMetadata } from '@/lib/seo';
import { getLatestNewsArticles } from '@/lib/markdown';
import Layout from '@/components/Layout';
import HomePageClient from '@/components/HomePageClient';

export async function generateMetadata() {
    return generateSEOMetadata('zh-CN', 'home');
}

export default async function HomePage() {
    const locale = 'zh-CN'; // 根页面默认语言为简体中文
    const [common, home, latestNews] = await Promise.all([
        getTranslations(locale, 'common'),
        getTranslations(locale, 'home'),
        getLatestNewsArticles(locale, 3),
    ]);

    const navigationPaths = getNavigationPaths(locale);
    const navigation = [
        {
            name: common.navigation.home,
            href: navigationPaths.find((p) => p.key === 'home')?.path || '/',
        },
        {
            name: common.navigation.products,
            href: navigationPaths.find((p) => p.key === 'products')?.path || '/products',
        },
        {
            name: common.navigation.news,
            href: navigationPaths.find((p) => p.key === 'news')?.path || '/news',
        },
        {
            name: common.navigation.support,
            href: navigationPaths.find((p) => p.key === 'support')?.path || '/support',
        },
        {
            name: common.navigation.about,
            href: navigationPaths.find((p) => p.key === 'about')?.path || '/about',
        },
    ];

    return (
        <Layout locale={locale} navigation={navigation} common={common}>
            <HomePageClient locale={locale} home={home} common={common} latestNews={latestNews} />
        </Layout>
    );
} 