35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { Metadata } from 'next';
|
|
import UnitPageClient from '@/components/pages/UnitPageClient';
|
|
import { getMod, getUnit } from '@/lib/api-server';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
interface Props {
|
|
params: { modId: string; raceId: string; unitId: string };
|
|
}
|
|
|
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
const [mod, unit] = await Promise.all([getMod(params.modId), getUnit(params.unitId)]);
|
|
if (!mod || !unit) {
|
|
return { title: 'Unit' };
|
|
}
|
|
const title = `${unit.name} — ${mod.name}`;
|
|
const description = unit.description
|
|
? `${unit.name} unit in ${mod.name} mod. ${unit.description}`
|
|
: `${unit.name} unit in ${mod.name} mod. Stats, weapons, abilities.`;
|
|
return {
|
|
title,
|
|
description,
|
|
alternates: {
|
|
canonical: `/mod/${params.modId}/race/${params.raceId}/unit/${params.unitId}`,
|
|
},
|
|
openGraph: {
|
|
title,
|
|
description,
|
|
},
|
|
};
|
|
}
|
|
|
|
export default function UnitPage() {
|
|
return <UnitPageClient />;
|
|
} |