Skip to content

Commit

Permalink
feat: add canonical urls
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanMorel committed Dec 8, 2023
1 parent 1762314 commit da3a7db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/journal/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export default async function JournalPage(): Promise<ReactElement> {

export const metadata = withMetadata({
title: "Journal",
description: "Add and view journal entries."
description: "Add and view journal entries.",
canonical: "/journal"
});
3 changes: 2 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export default async function RootLayout(props: Props): Promise<ReactElement> {

export const metadata = withMetadata({
title: "Alan Morel",
description: "Alan Morel - Software Engineer, Photographer, Music Producer"
description: "Alan Morel - Software Engineer, Photographer, Music Producer",
canonical: "/"
});
4 changes: 4 additions & 0 deletions src/helpers/server/MetadataHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type MetadataHandler = (props: MetadataProps) => Promise<Metadata>;
export type BaseMetadata = {
title: string;
description: string;
canonical: string;
image?: string;
};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit da3a7db

Please sign in to comment.