Moved to next js ssr
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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 />;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { Metadata } from 'next';
|
||||
import BuildingPageClient from '@/components/pages/BuildingPageClient';
|
||||
import { getBuilding, getMod } from '@/lib/api-server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
interface Props {
|
||||
params: { modId: string; raceId: string; buildingId: string };
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const [mod, building] = await Promise.all([getMod(params.modId), getBuilding(params.buildingId)]);
|
||||
if (!mod || !building) {
|
||||
return { title: 'Building' };
|
||||
}
|
||||
let buildingName = building.name;
|
||||
if (!buildingName) {
|
||||
buildingName = building.filename.replaceAll('_', ' ').replace('.rgd', '');
|
||||
}
|
||||
const title = `${buildingName} — ${mod.name}`;
|
||||
const description = `${buildingName} building in ${mod.name} mod. Stats, production, researches.`;
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: `/mod/${params.modId}/race/${params.raceId}/building/${params.buildingId}`,
|
||||
},
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default function BuildingPage() {
|
||||
return <BuildingPageClient />;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { Metadata } from 'next';
|
||||
import RacePageClient from '@/components/pages/RacePageClient';
|
||||
import { getMod, getRace } from '@/lib/api-server';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
interface Props {
|
||||
params: { modId: string; raceId: string };
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const [mod, race] = await Promise.all([getMod(params.modId), getRace(params.raceId)]);
|
||||
if (!mod || !race) {
|
||||
return { title: 'Race' };
|
||||
}
|
||||
const title = `${race.name} — ${mod.name}`;
|
||||
const description = `${race.name} race in ${mod.name} mod. Units, buildings and stats.`;
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
alternates: {
|
||||
canonical: `/mod/${params.modId}/race/${params.raceId}`,
|
||||
},
|
||||
openGraph: {
|
||||
title,
|
||||
description,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default function RacePage() {
|
||||
return <RacePageClient />;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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 />;
|
||||
}
|
||||
Reference in New Issue
Block a user