Skip to content

Commit

Permalink
fix: add canonical url in each page
Browse files Browse the repository at this point in the history
  • Loading branch information
leapalazzolo committed Feb 6, 2024
1 parent 67d0ee8 commit ccb10c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/explore/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import {
} from "@/utils/notion";
import { decodingSlug } from "@/utils/url";
import { fetchFilterOptions } from "@/lib/repository-metadata";
import { SITE_CONFIG } from "@/data/config";

interface IProps {
params: { slug: string };
}

export async function generateMetadata({ params }: IProps): Promise<Metadata> {
const url = SITE_CONFIG.url;
const { slug } = params;
const title = slug
.split("-")
Expand All @@ -24,6 +26,9 @@ export async function generateMetadata({ params }: IProps): Promise<Metadata> {

return {
title,
alternates: {
canonical: `${url}/${slug}`,
},
};
}

Expand Down
3 changes: 3 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const fontMono = Fira_Code({
});

export const metadata: Metadata = {
alternates: {
canonical: SITE_CONFIG.url,
},
title: {
default: SITE_CONFIG.name,
template: `%s | ${SITE_CONFIG.name}`,
Expand Down

0 comments on commit ccb10c2

Please sign in to comment.