Skip to content

Commit

Permalink
Revert "Added redirect"
Browse files Browse the repository at this point in the history
This reverts commit 0a5f6d3.
  • Loading branch information
erland-syafiq committed Jun 7, 2024
1 parent 8eb0455 commit 326438f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
30 changes: 4 additions & 26 deletions site/app/committees/[slug]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions site/middleware.js
Original file line number Diff line number Diff line change
@@ -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);
}

Expand Down

0 comments on commit 326438f

Please sign in to comment.