Skip to content

Commit

Permalink
Merge pull request #35 from erland-syafiq/redirects
Browse files Browse the repository at this point in the history
Redirects
  • Loading branch information
erland-syafiq authored Jun 10, 2024
2 parents 326438f + 2fe27f3 commit 65bfb07
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion site/app/committees/[slug]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default async function CommitteeDetailsPage({params}) {
</div>
</div>
<FormattedParagraph paragraphClassName="mt-3" text={committee.committee_bio} />
<a className="btn btn-primary btn-lg heroBtn" href={"/background_guides/" + committee.background_guide} target="_blank">
<a className="btn btn-primary btn-lg heroBtn" href={"/BackgroundGuides/" + committee.background_guide} target="_blank">
<h5 className="backgroundGuideButton">
Background Guide
</h5>
Expand Down
44 changes: 44 additions & 0 deletions site/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const committeeGroups = require("./app/data/committees.json");

function getOldSlugFromName(name) {
const normalized = name.replace(/[:(),<>]/g, "");
const nonSpaceName = normalized.replace(/ /g, "-");
const url = encodeURIComponent(nonSpaceName);
return url;
}

module.exports = {
async redirects() {
let redirects = [
{
source: "/Home/About",
destination: "/about",
permanent: true
},
{
source: "/Applicants/Create",
destination: "/register",
permanent: true
}
];

let committees = [];

for (const group of committeeGroups) {
for (const committee of group.committees) {
committees.push(committee);
}
}

const committeeRedirects = committees.map((committee) => {
return {
source: `/Committees/${getOldSlugFromName(committee.committee_name)}`,
destination: `/committees/${committee.id}`,
permanent: true
};
});

redirects = redirects.concat(committeeRedirects);
return redirects;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 65bfb07

Please sign in to comment.