From da3a7dba22961911d5ad2abbfd4225a3d0481fc8 Mon Sep 17 00:00:00 2001 From: Alan Morel Date: Fri, 8 Dec 2023 14:15:05 -0500 Subject: [PATCH] feat: add canonical urls --- app/journal/page.tsx | 3 ++- app/layout.tsx | 3 ++- src/helpers/server/MetadataHelper.ts | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/journal/page.tsx b/app/journal/page.tsx index 888a2d1..9ac4ac5 100644 --- a/app/journal/page.tsx +++ b/app/journal/page.tsx @@ -31,5 +31,6 @@ export default async function JournalPage(): Promise { export const metadata = withMetadata({ title: "Journal", - description: "Add and view journal entries." + description: "Add and view journal entries.", + canonical: "/journal" }); diff --git a/app/layout.tsx b/app/layout.tsx index 03121ab..8d37f5f 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -31,5 +31,6 @@ export default async function RootLayout(props: Props): Promise { export const metadata = withMetadata({ title: "Alan Morel", - description: "Alan Morel - Software Engineer, Photographer, Music Producer" + description: "Alan Morel - Software Engineer, Photographer, Music Producer", + canonical: "/" }); diff --git a/src/helpers/server/MetadataHelper.ts b/src/helpers/server/MetadataHelper.ts index 31b8306..bb85f3e 100644 --- a/src/helpers/server/MetadataHelper.ts +++ b/src/helpers/server/MetadataHelper.ts @@ -15,6 +15,7 @@ type MetadataHandler = (props: MetadataProps) => Promise; export type BaseMetadata = { title: string; description: string; + canonical: string; image?: string; }; @@ -46,6 +47,9 @@ const handle = "@AlanMorelX"; const buildMetadata = (base: BaseMetadata): Metadata => { return { metadataBase: new URL(`https://${Config.app.domain}`), + alternates: { + canonical: `https://${Config.app.domain}${base.canonical}` + }, title: base.title, description: base.description, applicationName: Config.app.name,