Skip to content

Commit

Permalink
fix: Layout components to include canonical URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko committed Sep 26, 2024
1 parent 55792f6 commit b75ca27
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/components/blog-page/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
---

<Layout title={post.title}>
<Layout title={post.title} canonical={canonicalUrl}>
<Header />
<div id="content">
<article>
Expand Down
5 changes: 4 additions & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import "../styles/main.css";
interface Props {
title: string;
canonical?: string;
}
const { title } = Astro.props;
const { title, canonical } = Astro.props;
---

<!doctype html>
Expand Down Expand Up @@ -47,6 +48,8 @@ const { title } = Astro.props;
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>

{canonical && <link rel="canonical" href={canonical} />}

<script is:inline>
window.dataLayer = window.dataLayer || [];

Expand Down
4 changes: 2 additions & 2 deletions src/pages/blog/blog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Layout from "../../layouts/Layout.astro";
import "../../styles/blog.css";
const posts = (await getCollection("blog")).sort(
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf()
);
---

<Layout title="Novage Blog">
<Layout title="Novage Blog" canonical="https://novage.com.ua/blog">
<Header />
<div id="content">
<article>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Layout from "../../layouts/Layout.astro";
import "../../styles/blog.css";
const posts = (await getCollection("blog")).sort(
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
(a, b) => new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf()
);
---

<Layout title="Novage Blog">
<Layout title="Novage Blog" canonical="https://novage.com.ua/blog">
<Header />
<div id="content">
<article>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Footer from "../components/shared/Footer.astro";
import PageHeader from "../components/shared/PageHeader.astro";
---

<Layout title="Novage">
<Layout title="Novage" canonical="https://novage.com.ua/">
<Header />
<div id="content">
<article>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/p2p-media-loader/demo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { P2PVideoDemo } from "p2p-media-loader-demo";
href="/_astro/_astro-entry_p2p-media-loader-demo.BMEc0IOl.css"
/>

<Layout title="P2P Media Loader">
<Layout
title="P2P Media Loader"
canonical="https://novage.com.ua/p2p-media-loader/demo"
>
<Header />

<div id="content">
Expand Down
5 changes: 4 additions & 1 deletion src/pages/p2p-media-loader/overview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import Layout from "../../layouts/Layout.astro";
import img from "../../../public/images/p2p-assisted-media-delivery.png";
---

<Layout title="P2P Media Loader">
<Layout
title="P2P Media Loader"
canonical="https://novage.com.ua/p2p-media-loader/overview"
>
<Header />
<div id="content">
<article>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/p2p-media-loader/technical-overview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import Layout from "../../layouts/Layout.astro";
import img from "../../../public/images/p2p-media-loader-network.png";
---

<Layout title="P2P Media Loader">
<Layout
title="P2P Media Loader"
canonical="https://novage.com.ua/p2p-media-loader/technical-overview"
>
<Header />
<div id="content">
<article>
Expand Down

0 comments on commit b75ca27

Please sign in to comment.