Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 77 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { NextConfig } from "next";
import createMDX from "@next/mdx";
import rehypeSlug from "rehype-slug";
import {
getProvincialSlugs,
getMunicipalitiesByProvince,
} from "./src/lib/jurisdictions";

const nextConfig: NextConfig = {
/* config options here */
Expand Down Expand Up @@ -36,13 +40,85 @@ const nextConfig: NextConfig = {
return config;
},
async redirects() {
return [
const redirects: Array<{
source: string;
destination: string;
permanent: boolean;
}> = [
// Permanent redirects (keep these)
{
source: "/:locale/tax-calculator",
destination: "/:locale/tax-visualizer",
permanent: true,
},
];

// ========================================================================
// TEMPORARY REDIRECTS FOR OLD URL STRUCTURE
// TODO: REMOVE AFTER 2026-03-01
// These redirects support backward compatibility for the old URL structure
// that existed before the provincial/municipal/federal restructuring.
// After March 1, 2026, these can be safely removed as users will have
// had sufficient time to update bookmarks and external links.
// ========================================================================

// Load jurisdiction data (uses cached static-data.json internally)
const provinces = getProvincialSlugs();
const municipalitiesByProvince = getMunicipalitiesByProvince();

// Redirect old federal spending/budget URLs to new structure
redirects.push(
{
source: "/:locale/spending",
destination: "/:locale/federal/spending",
permanent: true,
},
{
source: "/:locale/budget",
destination: "/:locale/federal/budget",
permanent: true,
},
);

// Add redirects for old provincial URLs
for (const province of provinces) {
redirects.push(
{
source: `/:locale/${province}`,
destination: `/:locale/provincial/${province}`,
permanent: true,
},
{
source: `/:locale/${province}/:department*`,
destination: `/:locale/provincial/${province}/:department*`,
permanent: true,
},
);
}

// Add redirects for old municipal URLs
for (const { province, municipalities } of municipalitiesByProvince) {
for (const municipality of municipalities) {
redirects.push(
{
source: `/:locale/${municipality.slug}`,
destination: `/:locale/municipal/${province}/${municipality.slug}`,
permanent: true,
},
{
source: `/:locale/${municipality.slug}/:path*`,
destination: `/:locale/municipal/${province}/${municipality.slug}/:path*`,
permanent: true,
},
);
}
}

// ========================================================================
// END TEMPORARY REDIRECTS - REMOVE AFTER 2026-03-01
// ========================================================================

return redirects;
},
async rewrites() {
return [
Expand Down
Loading