diff --git a/src/components/SEOMeta.astro b/src/components/SEOMeta.astro
index 3fd181b..5edbe44 100644
--- a/src/components/SEOMeta.astro
+++ b/src/components/SEOMeta.astro
@@ -4,6 +4,7 @@ interface Props {
description?: string
favicon?: string
faviconMimeType?: string
+ canonicalURL?: string | undefined
keywords?: string
author?: string
robots?: string
@@ -14,16 +15,20 @@ const {
description,
favicon,
faviconMimeType,
+ canonicalURL,
keywords,
author,
robots,
} = Astro.props
+
+const _canonicalURL = canonicalURL || Astro.url.href
---
+{_canonicalURL && }
{title}
diff --git a/src/content/config.ts b/src/content/config.ts
index 71663c2..0528ef9 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -8,6 +8,7 @@ const leetcodeSolutionCollection = defineCollection({
pubDate: z.string(),
difficulty: z.string(),
tags: z.array(z.string()),
+ canonicalURL: z.string().optional(),
}),
})
diff --git a/src/layouts/AppLayout.astro b/src/layouts/AppLayout.astro
index 6a7d42a..c4d2168 100644
--- a/src/layouts/AppLayout.astro
+++ b/src/layouts/AppLayout.astro
@@ -9,12 +9,13 @@ import siteConfig from '@/configs/site'
export interface Props {
title: string
description: string
+ canonicalURL?: string | undefined
author: string
headerCssClasses?: string
keywords?: string[]
}
-const { title, description = '', author, headerCssClasses = '' } = Astro.props
+const { title, description = '', canonicalURL, author, headerCssClasses = '' } = Astro.props
const { favicon, faviconMimeType } = siteConfig
const pageDescription =
description.length > 0 ? description : `${title} - ${siteConfig.description}`
@@ -26,6 +27,7 @@ const pageDescription =