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
26 changes: 17 additions & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,37 @@ import {
SkipLink,
ThemeColorSync,
} from "@/support/theme";
import { INDEXABLE_ROBOTS } from "@hraness/web-discovery";
import { JsonLdScript } from "@hraness/web-discovery/json-ld";
import type { Metadata, Viewport } from "next";
import type { ReactNode } from "react";
import "./globals.css";
import { PostHogAnalytics } from "./posthog-analytics";
import { websiteJsonLd } from "./seo";
import { SITE_ORIGIN, site, socialMetadata } from "./site";
import { SITE_ORIGIN, site } from "./site";

export const metadata: Metadata = {
metadataBase: new URL(SITE_ORIGIN),
title: {
default: site.title,
default: site.applicationName,
template: site.titleTemplate,
},
description: site.description,
applicationName: site.applicationName,
alternates: {
canonical: "/",
},
formatDetection: { address: false, email: false, telephone: false },
robots: INDEXABLE_ROBOTS,
...socialMetadata(site.title, site.description, "/"),
openGraph: {
type: "website",
locale: "en_US",
siteName: site.name,
images: [{
alt: site.socialImageAlt,
height: 630,
url: "/opengraph-image",
width: 1200,
}],
},
twitter: {
card: "summary_large_image",
images: [{ alt: site.socialImageAlt, url: "/opengraph-image" }],
},
};

export const viewport: Viewport = {
Expand Down
29 changes: 20 additions & 9 deletions app/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ describe("stripehistory.com public identity", () => {
},
sitemap: `${SITE_ORIGIN}/sitemap.xml`,
});
expect(metadata.robots).toMatchObject({ index: true, follow: true });
});

test("keeps canonical metadata on stripehistory.com", () => {
test("keeps only site-wide defaults that other routes can inherit", () => {
expect(robots()).toMatchObject({ host: SITE_ORIGIN });
expect(manifest()).toMatchObject({
description: site.description,
Expand All @@ -68,14 +67,26 @@ describe("stripehistory.com public identity", () => {
expect(new URL(metadata.metadataBase ?? "https://invalid.example").origin).toBe(
SITE_ORIGIN,
);
expect(metadata.alternates).toEqual({ canonical: "/" });
expect(metadata.title).toEqual({
default: site.title,
template: site.titleTemplate,
expect(metadata).toMatchObject({
applicationName: site.applicationName,
title: {
default: site.applicationName,
template: site.titleTemplate,
},
openGraph: {
locale: "en_US",
siteName: site.name,
type: "website",
},
});
expect(metadata.description).toBe(site.description);
expect(metadata.openGraph?.title).toBe(site.title);
expect(metadata.twitter?.title).toBe(site.title);
expect(metadata).not.toHaveProperty("description");
expect(metadata).not.toHaveProperty("robots");
expect(metadata.alternates).toBeUndefined();
expect(metadata.openGraph).not.toHaveProperty("url");
expect(metadata.openGraph).not.toHaveProperty("title");
expect(metadata.openGraph).not.toHaveProperty("description");
expect(metadata.twitter).not.toHaveProperty("title");
expect(metadata.twitter).not.toHaveProperty("description");
expect(socialImageAlt).toBe(site.socialImageAlt);
});

Expand Down
16 changes: 16 additions & 0 deletions app/not-found.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe, expect, test } from "bun:test";
import { NOINDEX_ROBOTS } from "@hraness/web-discovery";

import { metadata } from "./not-found";

describe("stripehistory.com not-found metadata", () => {
test("uses a distinct noindex page instead of the homepage identity", () => {
expect(metadata).toEqual({
title: "Page not found",
description: "The requested Stripe history page does not exist.",
robots: NOINDEX_ROBOTS,
});
expect(metadata.alternates).toBeUndefined();
expect(metadata.openGraph).toBeUndefined();
});
});
15 changes: 13 additions & 2 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { NOINDEX_ROBOTS } from "@hraness/web-discovery";
import type { Metadata } from "next";
import Link from "next/link";

import { SiteFooter } from "./site-footer";
import { SiteHeader } from "./site-header";

const notFoundTitle = "Page not found";
const notFoundDescription = "The requested Stripe history page does not exist.";

export const metadata: Metadata = {
title: notFoundTitle,
description: notFoundDescription,
robots: NOINDEX_ROBOTS,
};

export default function NotFound() {
return (
<main className="plain-page stripe-history-main stripe-history-state" id="main-content">
<SiteHeader />
<section aria-labelledby="not-found-heading" className="stripe-history-section">
<h1 id="not-found-heading">Page not found</h1>
<p>The requested Stripe history page does not exist.</p>
<h1 id="not-found-heading">{notFoundTitle}</h1>
<p>{notFoundDescription}</p>
<p><Link href="/">Browse Stripe company history</Link></p>
</section>
<SiteFooter />
Expand Down
4 changes: 4 additions & 0 deletions app/page.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { describe, expect, test } from "bun:test";
import { INDEXABLE_ROBOTS } from "@hraness/web-discovery";
import { loadHistory } from "@/lib/content";
import { renderToStaticMarkup } from "react-dom/server";

import Home, { generateMetadata } from "./page";
import { site } from "./site";

describe("canonical stripehistory.com history", () => {
test("publishes root-canonical history metadata", async () => {
Expand All @@ -12,6 +14,8 @@ describe("canonical stripehistory.com history", () => {

expect(metadata).toMatchObject({
alternates: { canonical: "/" },
description: site.description,
robots: INDEXABLE_ROBOTS,
title: expectedTitle,
});
expect(metadata.openGraph).toMatchObject({
Expand Down
2 changes: 2 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { loadHistory } from "@/lib/content";
import { INDEXABLE_ROBOTS } from "@hraness/web-discovery";
import { JsonLdScript } from "@hraness/web-discovery/json-ld";
import type { Metadata } from "next";

Expand All @@ -19,6 +20,7 @@ export async function generateMetadata(): Promise<Metadata> {
title,
description: site.description,
alternates: { canonical: "/" },
robots: INDEXABLE_ROBOTS,
...socialMetadata(`${title} | ${site.domain}`, site.description, "/"),
};
}
Expand Down