From 310b7f993f81069c8dfb1e4fccc490d5e16b18a1 Mon Sep 17 00:00:00 2001 From: Axel Pettersson Date: Sat, 30 Sep 2023 03:48:14 +0200 Subject: [PATCH] Fix some navigation --- apps/web/app/parti/[party]/page.tsx | 14 ++++++++++---- apps/web/lib/navigation.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/web/app/parti/[party]/page.tsx b/apps/web/app/parti/[party]/page.tsx index a6b9e1099..84f8dc198 100644 --- a/apps/web/app/parti/[party]/page.tsx +++ b/apps/web/app/parti/[party]/page.tsx @@ -14,11 +14,15 @@ import { getParty } from "@lib/api/party/get-party"; interface PageProps { params: { - party: Party; + party: Lowercase; }; } -export async function generateMetadata({ params: { party } }: PageProps) { +export async function generateMetadata({ + params: { party: partyAbbreviation }, +}: PageProps) { + const party = partyAbbreviation.toUpperCase() as Party; + if (!Object.values(Party).includes(party)) { return { title: ERROR_404_TITLE }; } @@ -32,8 +36,10 @@ export async function generateMetadata({ params: { party } }: PageProps) { } export default async function PartyPage({ - params: { party: partyAbbreviation }, + params: { party: partyAbbreviationLowercase }, }: PageProps) { + const partyAbbreviation = + partyAbbreviationLowercase.toLocaleUpperCase() as Party; if (!Object.values(Party).includes(partyAbbreviation)) { return notFound(); } @@ -108,6 +114,6 @@ export async function generateStaticParams() { const parties = Object.values(Party); return parties.map((party) => ({ - party, + party: party.toLocaleLowerCase(), })); } diff --git a/apps/web/lib/navigation.tsx b/apps/web/lib/navigation.tsx index fc0dd46b2..c738504a2 100644 --- a/apps/web/lib/navigation.tsx +++ b/apps/web/lib/navigation.tsx @@ -26,7 +26,7 @@ export const routes = { return `/standpunkter/${id}`; }, party(party: Party) { - return `/parti/${party}`; + return `/parti/${party.toLocaleLowerCase()}`; }, members: "/ledamot", member(id: string) {