From b75ca273560150cd3b872c28693534b77de5f23b Mon Sep 17 00:00:00 2001 From: DimaDemchenko Date: Thu, 26 Sep 2024 17:58:51 +0300 Subject: [PATCH] fix: Layout components to include canonical URLs --- src/components/blog-page/Post.astro | 3 ++- src/layouts/Layout.astro | 5 ++++- src/pages/blog/blog.astro | 4 ++-- src/pages/blog/index.astro | 4 ++-- src/pages/index.astro | 2 +- src/pages/p2p-media-loader/demo.astro | 5 ++++- src/pages/p2p-media-loader/overview.astro | 5 ++++- src/pages/p2p-media-loader/technical-overview.astro | 5 ++++- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/components/blog-page/Post.astro b/src/components/blog-page/Post.astro index b9ff24f..7fda186 100644 --- a/src/components/blog-page/Post.astro +++ b/src/components/blog-page/Post.astro @@ -6,9 +6,10 @@ import Layout from "../../layouts/Layout.astro"; import "../../styles/blog.css"; const post = Astro.props.frontmatter ?? Astro.props; +const canonicalUrl = `https://example.com/blog/${post.title}`; --- - +
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 6511d79..2b73051 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -3,9 +3,10 @@ import "../styles/main.css"; interface Props { title: string; + canonical?: string; } -const { title } = Astro.props; +const { title, canonical } = Astro.props; --- @@ -47,6 +48,8 @@ const { title } = Astro.props; content="width=device-width, initial-scale=1, shrink-to-fit=no" /> + {canonical && } +