Skip to content
Merged
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
8 changes: 6 additions & 2 deletions src/app/builders/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound, permanentRedirect } from "next/navigation";
import type { Metadata } from "next";
import Image from "next/image";
import Link from "next/link";
Expand All @@ -15,7 +15,7 @@ export async function generateMetadata({
return {
title: `${builder.name}: ${builder.tagline}`,
description: builder.quote ?? undefined,
alternates: { canonical: `/builders/${slug}` },
alternates: { canonical: `/builders/${builder.slug}` },
openGraph: {
title: `${builder.name}: ${builder.tagline} | Build Canada`,
description: builder.quote ?? undefined,
Expand All @@ -41,6 +41,10 @@ export default async function BuilderPage({
notFound();
}

if (builder.slug !== slug) {
permanentRedirect(`/builders/${builder.slug}`);
}

return (
<div className="mx-[10px] my-[10px] border border-border-light bg-bg">
<article className="animate-fade-in max-w-2xl mx-auto px-5 pt-[50px] pb-[60px]">
Expand Down
8 changes: 6 additions & 2 deletions src/app/memos/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound, permanentRedirect } from "next/navigation";
import type { Metadata } from "next";
import Image from "next/image";
import { fetchMemo, fetchMemos, getSiteConfig } from "@/lib/api";
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function generateMetadata({
return {
title,
description,
alternates: { canonical: `/memos/${slug}` },
alternates: { canonical: `/memos/${memo.slug}` },
openGraph: {
title,
description,
Expand Down Expand Up @@ -73,6 +73,10 @@ export default async function MemoDetailPage({
notFound();
}

if (memo.slug !== slug) {
permanentRedirect(`/memos/${memo.slug}`);
}

const authorImage =
memo.author.name === "Build Canada"
? "/assets/logos/buildcanada-logo-square.svg"
Expand Down
7 changes: 6 additions & 1 deletion src/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound, permanentRedirect } from "next/navigation";
import type { Metadata } from "next";
import Link from "next/link";
import { fetchPost, fetchPosts, getSiteConfig } from "@/lib/api";
Expand Down Expand Up @@ -39,6 +39,7 @@ export async function generateMetadata({
return {
title,
description,
alternates: { canonical: `/posts/${post.slug}` },
openGraph: {
title,
description,
Expand Down Expand Up @@ -68,6 +69,10 @@ export default async function PostDetailPage({
notFound();
}

if (post.slug !== slug) {
permanentRedirect(`/posts/${post.slug}`);
}

const date = new Date(post.publishedAt || post.createdAt).toLocaleDateString(
"en-CA",
{ year: "numeric", month: "long", day: "numeric" },
Expand Down
8 changes: 6 additions & 2 deletions src/app/toronto/memos/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound, permanentRedirect } from "next/navigation";
import type { Metadata } from "next";
import Image from "next/image";
import { fetchMemo, fetchMemos, getSiteConfig } from "@/lib/api";
Expand Down Expand Up @@ -48,7 +48,7 @@ export async function generateMetadata({
return {
title,
description,
alternates: { canonical: `${BASE_PATH}/${slug}` },
alternates: { canonical: `${BASE_PATH}/${memo.slug}` },
openGraph: {
title,
description,
Expand Down Expand Up @@ -79,6 +79,10 @@ export default async function TorontoMemoDetailPage({
notFound();
}

if (memo.slug !== slug) {
permanentRedirect(`${BASE_PATH}/${memo.slug}`);
}

const authorImage = memo.author.photo;

const keyMessages = memo.keyMessages;
Expand Down
Loading