chore: add name to page titles

This commit is contained in:
Oliver Davies 2023-10-04 01:09:39 +01:00
parent 280db0d969
commit 25dcd4dd37
3 changed files with 6 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import Banner from "../components/Banner.astro";
import Navbar from "../components/Navbar.astro"; import Navbar from "../components/Navbar.astro";
export interface Props { export interface Props {
isFront: boolean;
title: string; title: string;
} }
@ -39,6 +40,7 @@ const footerLinks = [
]; ];
const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString().replace(/\/$/, ""); const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString().replace(/\/$/, "");
const isFrontPage = Astro.props.isFront;
--- ---
<!DOCTYPE html> <!DOCTYPE html>
@ -54,7 +56,7 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString().replace(
rel="stylesheet" rel="stylesheet"
/> />
<link rel="canonical" href={canonicalURL} /> <link rel="canonical" href={canonicalURL} />
<title>{title}</title> <title>{isFrontPage ? title : `${title} | Oliver Davies`}</title>
<script <script
defer defer
data-domain="oliverdavies.uk" data-domain="oliverdavies.uk"

View file

@ -2,10 +2,10 @@
import BaseLayout from "./Layout.astro"; import BaseLayout from "./Layout.astro";
import Markdown from "~/components/Markdown.astro"; import Markdown from "~/components/Markdown.astro";
const { title } = Astro.props.frontmatter || Astro.props; const { isFront, title } = Astro.props.frontmatter || Astro.props;
--- ---
<BaseLayout title={title}> <BaseLayout isFront={isFront || false} title={title}>
<Markdown> <Markdown>
<slot /> <slot />
</Markdown> </Markdown>

View file

@ -1,6 +1,7 @@
--- ---
layout: ~/layouts/PageLayout.astro layout: ~/layouts/PageLayout.astro
title: Oliver Davies - Software Developer and Drupal Expert title: Oliver Davies - Software Developer and Drupal Expert
isFront: true
--- ---
import { numberOfYears } from '~/utils'; import { numberOfYears } from '~/utils';