import type { Metadata } from 'next';
import ModPageClient from '@/components/pages/ModPageClient';
import { getMod } from '@/lib/api-server';

export const dynamic = 'force-dynamic';

interface Props {
    params: { modId: string };
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
    const mod = await getMod(params.modId);
    if (!mod) {
        return { title: 'Mod' };
    }
    const title = `${mod.name} (${mod.version})`;
    const description = `Dawn of War wiki. ${mod.name} mod. Units, races, buildings and stats.`;
    return {
        title,
        description,
        alternates: {
            canonical: `/mod/${params.modId}`,
        },
        openGraph: {
            title,
            description,
        },
    };
}

export default function ModPage() {
    return <ModPageClient />;
}