Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { siteConfig } from "@/lib/site";
// Edit each page once; search and social metadata use the same fields.
export const pages = {
home: {
title: siteConfig.title,
title: siteConfig.name,
path: "/",
},
journey: {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/page-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export interface PageMetadataInput {

export function buildPageMetadata({
title: label,
description = siteConfig.description,
description = siteConfig.title,
path,
type = "website",
image = siteConfig.shareImage,
alternates,
robots,
}: PageMetadataInput) {
const title = `${siteConfig.name} | ${label}`;
const title = path === "/" ? label : `${label} | ${siteConfig.name}`;
const images = [{ ...image }];

return {
Expand Down
18 changes: 10 additions & 8 deletions tests/site-seo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ test("main page content produces consistent search and social metadata", async (

for (const page of Object.values(pages)) {
const metadata = buildPageMetadata(page);
expect(metadata.title.absolute).toBe(`${siteConfig.name} | ${page.title}`);
expect(metadata.description).toBe(siteConfig.description);
expect(metadata.title.absolute).toBe(
page.path === "/" ? siteConfig.name : `${page.title} | ${siteConfig.name}`
);
expect(metadata.description).toBe("Software and Writing");
expect(metadata.openGraph.title).toBe(metadata.title.absolute);
expect(metadata.twitter.title).toBe(metadata.title.absolute);
expect(metadata.openGraph.description).toBe(metadata.description);
Expand All @@ -148,9 +150,9 @@ test("main page content produces consistent search and social metadata", async (
}

const minimal = buildPageMetadata({ title: "Example", path: "/example" });
expect(minimal.description).toBe(siteConfig.description);
expect(minimal.openGraph.description).toBe(siteConfig.description);
expect(minimal.twitter.description).toBe(siteConfig.description);
expect(minimal.description).toBe("Software and Writing");
expect(minimal.openGraph.description).toBe("Software and Writing");
expect(minimal.twitter.description).toBe("Software and Writing");
expect(minimal.openGraph.type).toBe("website");
expect(Object.hasOwn(minimal, "robots")).toBe(false);
const { buildProfilePageJsonLd } = await import("../src/lib/structured-data");
Expand All @@ -163,7 +165,7 @@ test("main page content produces consistent search and social metadata", async (
await import("../src/lib/structured-data");
const collection = buildBlogCollectionJsonLd([]);
expect(collection.name).toBe(buildPageMetadata(pages.writing).title.absolute);
expect(collection.description).toBe(siteConfig.description);
expect(collection.description).toBe("Software and Writing");
expect(collection.url).toBe(publicUrl(pages.writing.path));
const { resumeData } = await import("../src/content/resume");
const { siteNavigation } = await import("../src/content/site");
Expand All @@ -176,7 +178,7 @@ test("main page content produces consistent search and social metadata", async (
expect(page.path).toBe(link.path);
expect(page.title).not.toBe(link.title);
}
expect(pages.home.title).toBe(siteConfig.title);
expect(pages.home.title).toBe(siteConfig.name);
expect(pages.home.title).not.toBe(siteConfig.author.role);
expect(siteConfig.shareImage.alt).toContain(siteConfig.name);
const { default: sharp } = await import("sharp");
Expand Down Expand Up @@ -221,7 +223,7 @@ test("blog metadata and JSON-LD share authored fields, URLs, images and dates",
const metadata = buildBlogMetadata(article);
const schema = buildBlogPostingJsonLd(article);
expect(metadata.title.absolute).toBe(
`${siteConfig.name} | ${post.metadata.title}`
`${post.metadata.title} | ${siteConfig.name}`
);
expect(metadata.openGraph.title).toBe(metadata.title.absolute);
expect(metadata.twitter.title).toBe(metadata.title.absolute);
Expand Down
Loading