Skip to content

Commit ff52d94

Browse files
committed
feat: set page titles for all routes
1 parent 5664c8b commit ff52d94

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/layouts/BaseLayout.astro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import '../styles/global.css';
33
import Navigation from '@/components/Navigation';
44
import ModeToggle from '@/components/ModeToggle';
55
6-
const pageTitle = 'Home Page';
6+
type Props = {
7+
pageTitle: string;
8+
};
9+
10+
const { pageTitle } = Astro.props;
11+
const siteTitle = "Joey's Blog";
12+
const fullTitle = pageTitle ? `${pageTitle} | ${siteTitle}` : siteTitle;
13+
714
const pathname = Astro.url.pathname;
815
---
916

@@ -41,7 +48,7 @@ const pathname = Astro.url.pathname;
4148
/>
4249
<meta name="viewport" content="width=device-width" />
4350
<meta name="generator" content={Astro.generator} />
44-
<title>{pageTitle}</title>
51+
<title>{fullTitle}</title>
4552
</head>
4653
<body class="pb-32 px-4">
4754
<header class="pt-8 pb-8 sm:pb-16">

src/layouts/PostLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { post } = Astro.props;
88
const { title, pubDate, description, update } = post.data;
99
---
1010

11-
<BaseLayout>
11+
<BaseLayout pageTitle={title}>
1212
<Prose>
1313
<PostMeta title={title} pubDate={pubDate} description={description} />
1414
<slot />

src/pages/about.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const [about] = await getCollection('about');
88
const { Content } = await render(about);
99
---
1010

11-
<BaseLayout>
11+
<BaseLayout pageTitle="About">
1212
<Prose>
1313
<Content />
1414
</Prose>

src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { getCollection } from 'astro:content';
66
const allPosts = await getCollection('posts');
77
---
88

9-
<BaseLayout>
9+
<BaseLayout pageTitle="Home">
1010
<PostList posts={allPosts} />
1111
</BaseLayout>

0 commit comments

Comments
 (0)