diff --git a/site/app/committees/[slug]/page.jsx b/site/app/committees/[slug]/page.jsx index bc2cd48..769b78e 100644 --- a/site/app/committees/[slug]/page.jsx +++ b/site/app/committees/[slug]/page.jsx @@ -3,8 +3,7 @@ import fetchStaticJSON from '@/app/utils/fetchStaticJSON'; import UserCard from '@/app/components/UserCard'; import './CommitteeDetails.css'; import FormattedParagraph from '@/app/components/FormattedParagraph'; -import { notFound, permanentRedirect } from 'next/navigation'; -import { revalidateTag } from 'next/cache'; +import { notFound } from 'next/navigation'; function findCommittee(committeeGroups, queryId) { @@ -19,25 +18,6 @@ function findCommittee(committeeGroups, queryId) { return null; } -function findCommitteeFromName(committeeGroups, queryId) { - console.log(queryId); - for (const group of committeeGroups) { - for (const committee of group.committees) { - const urlName = committee.committee_name - .replace(/[:(),<>]/g, "") // Remove specified characters - .replace(/ /g, "-") // Replace spaces with hyphens - .toLowerCase(); - console.log(urlName); - console.log(decodeURI(queryId)); - if (urlName == decodeURI(queryId)) { - return committee; - } - } - } - - return null; -} - export async function generateMetadata({ params }) { const committeeGroups = await fetchStaticJSON("/app/data/committees.json"); const id = params.slug; @@ -63,12 +43,10 @@ export default async function CommitteeDetailsPage({params}) { const committee = findCommittee(committeeGroups, id); if (!committee) { - // Attempts to find a matching url from the old ASP.NET url system - const alt_committee = findCommitteeFromName(committeeGroups, id); - if (!alt_committee) { - notFound(); + return { + title: "Page not found", + description: "Page you're looking for doesn't exist. ." } - permanentRedirect(`/committees/${alt_committee.id}`); } const isOneChair = committee.co_chair_name == null; diff --git a/site/middleware.js b/site/middleware.js index acbeea4..d0efa23 100644 --- a/site/middleware.js +++ b/site/middleware.js @@ -1,9 +1,10 @@ import { NextResponse } from "next/server"; export function middleware(request) { - if (/[A-Z]/.test(request.nextUrl.pathname)) { + + if (/[A-Z]/.test(request.nextUrl.pathName)) { const url = request.nextUrl.clone(); - url.pathname = url.pathname.toLowerCase(); + url.pathname = pathname.toLowerCase(); return NextResponse.redirect(url); }