Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/apps
diff options
context:
space:
mode:
authorLeitwolf112026-11-17 15:12:16 +0300
committerLeitwolf112026-11-17 15:12:16 +0300
commit0036d3f1348f13dda83f97cba8a0a135abe5a7da (patch)
tree6e29aa1a79b993b31409050b4bdff34dc12414b0 /apps
parent477625cd75db2295d0f05bce206d9ea1b5b13ef2 (diff)
downloadprogmaweb-site/not-found.tar.gz
Give an unknown address a page of the site, in the visitor's languagesite/not-found
progmasoft.com/example.txt showed Next's own "404: This page could not be found" with two titles. Every host now answers such an address with the header and the footer of the site around one sentence, "We are sorry, the page you requested cannot be found.", and a line on why, in the language of the visitor, with the status 404 and no index (app/not-found.tsx, notFound messages in every locale). On product.progmasoft.com an unknown address reaches the page of a product and asks for the not-found page; its metadata now gives the not-found title too, not the bare site name. Tests: every host answers /example.txt with 404, the sentence, the header and the footer, one title, and no sideways scroll; the page speaks German with a German cookie. 160 layout tests pass; tsc, eslint, 42 unit tests and the build pass. Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'apps')
-rw-r--r--apps/web/app/not-found.tsx36
-rw-r--r--apps/web/app/products/[slug]/page.tsx11
-rw-r--r--apps/web/app/site.css23
-rw-r--r--apps/web/e2e/not-found.spec.ts51
-rw-r--r--apps/web/lib/localization.ts20
5 files changed, 138 insertions, 3 deletions
diff --git a/apps/web/app/not-found.tsx b/apps/web/app/not-found.tsx
new file mode 100644
index 0000000..f6c510a
--- /dev/null
+++ b/apps/web/app/not-found.tsx
@@ -0,0 +1,36 @@
+// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import type { Metadata } from "next";
+import { Footer } from "@/components/Footer";
+import { SiteHeader } from "@/components/SiteHeader";
+import { getLocale } from "@/lib/locale.server";
+import { getMessages } from "@/lib/localization";
+import "./site.css";
+
+export async function generateMetadata(): Promise<Metadata> {
+ const { notFound } = getMessages(await getLocale());
+ return { title: notFound.pageTitle, robots: { index: false } };
+}
+
+/**
+ * What every host of the site shows for an address it has no page for: the
+ * header and the footer of the site around one sentence, in the language of
+ * the visitor, with the status 404.
+ */
+export default async function NotFound() {
+ const locale = await getLocale();
+ const { notFound } = getMessages(locale);
+ return (
+ <div className="pm-page">
+ <SiteHeader locale={locale} />
+ <main className="pm-not-found">
+ <div className="pm-shell">
+ <h1>{notFound.title}</h1>
+ <p>{notFound.text}</p>
+ </div>
+ </main>
+ <Footer locale={locale} />
+ </div>
+ );
+}
diff --git a/apps/web/app/products/[slug]/page.tsx b/apps/web/app/products/[slug]/page.tsx
index 664278b..311810d 100644
--- a/apps/web/app/products/[slug]/page.tsx
+++ b/apps/web/app/products/[slug]/page.tsx
@@ -10,7 +10,7 @@ import {
StatusBadge,
} from "@/components/ProductCatalog";
import { getLocale } from "@/lib/locale.server";
-import { forwardArrow } from "@/lib/localization";
+import { forwardArrow, getMessages } from "@/lib/localization";
import { getCatalogMessages, isProductSlug, products } from "@/lib/products";
interface ProductPageProps {
@@ -21,10 +21,15 @@ export async function generateMetadata({
params,
}: ProductPageProps): Promise<Metadata> {
const { slug } = await params;
+ const locale = await getLocale();
if (!isProductSlug(slug)) {
- return {};
+ // The page answers with the not-found page; its title says so too.
+ return {
+ title: getMessages(locale).notFound.pageTitle,
+ robots: { index: false },
+ };
}
- const catalog = getCatalogMessages(await getLocale());
+ const catalog = getCatalogMessages(locale);
return {
title: `${products[slug].name} · ${catalog.categories[products[slug].category]}`,
description: catalog.products[slug].description,
diff --git a/apps/web/app/site.css b/apps/web/app/site.css
index 58106e3..93df053 100644
--- a/apps/web/app/site.css
+++ b/apps/web/app/site.css
@@ -565,3 +565,26 @@
padding-top: 24px;
border-top: 1px solid var(--line);
}
+
+/* The page of an address the site has none for: one sentence in the middle of the page. */
+.pm-not-found {
+ display: grid;
+ min-height: 60vh;
+ align-items: center;
+ padding-block: 96px;
+ text-align: center;
+}
+
+.pm-not-found h1 {
+ margin: 0 auto;
+ max-width: 980px;
+ font-size: clamp(1.9rem, 4vw, 2.6rem);
+ letter-spacing: -0.02em;
+ line-height: 1.2;
+}
+
+.pm-not-found p {
+ margin: 18px auto 0;
+ max-width: 640px;
+ color: var(--ink-650);
+}
diff --git a/apps/web/e2e/not-found.spec.ts b/apps/web/e2e/not-found.spec.ts
new file mode 100644
index 0000000..7be30f5
--- /dev/null
+++ b/apps/web/e2e/not-found.spec.ts
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import { expect, test } from "@playwright/test";
+
+const hosts = [
+ "progmasoft.com",
+ "account.progmasoft.com",
+ "viget.progmasoft.com",
+ "product.progmasoft.com",
+];
+
+for (const host of hosts) {
+ test(`${host} answers an unknown address with its own page and 404`, async ({
+ page,
+ }) => {
+ const response = await page.goto(`http://${host}/example.txt`);
+ expect(response?.status()).toBe(404);
+ await expect(page.locator("h1")).toHaveText(
+ "We are sorry, the page you requested cannot be found.",
+ );
+ await expect(page.locator("header.site-header")).toBeVisible();
+ await expect(page.locator("footer.site-footer")).toBeVisible();
+ expect(await page.locator("title").count()).toBe(1);
+ await expect(page).toHaveTitle("Page not found · Progmasoft");
+ const overflow = await page.evaluate(
+ () =>
+ document.documentElement.scrollWidth -
+ document.documentElement.clientWidth,
+ );
+ expect(overflow).toBe(0);
+ });
+}
+
+test("the page of an unknown address speaks the visitor's language", async ({
+ page,
+ context,
+}) => {
+ await context.addCookies([
+ {
+ name: "progmasoft_locale",
+ value: "de-DE",
+ domain: ".progmasoft.com",
+ path: "/",
+ },
+ ]);
+ await page.goto("http://viget.progmasoft.com/nope");
+ await expect(page.locator("h1")).toHaveText(
+ "Es tut uns leid, die angeforderte Seite wurde nicht gefunden.",
+ );
+});
diff --git a/apps/web/lib/localization.ts b/apps/web/lib/localization.ts
index f2a012f..e1c1c83 100644
--- a/apps/web/lib/localization.ts
+++ b/apps/web/lib/localization.ts
@@ -163,6 +163,11 @@ export const messages = {
dark: "Dark",
language: "Language",
},
+ notFound: {
+ title: "We are sorry, the page you requested cannot be found.",
+ text: "The address may be misspelled, or the page you are looking for is no longer available.",
+ pageTitle: "Page not found",
+ },
footer: {
summary:
"Developer tools and data infrastructure built with durable contracts.",
@@ -424,6 +429,11 @@ export const messages = {
dark: "Dunkel",
language: "Sprache",
},
+ notFound: {
+ title: "Es tut uns leid, die angeforderte Seite wurde nicht gefunden.",
+ text: "Die Adresse ist vielleicht falsch geschrieben, oder die gesuchte Seite ist nicht mehr verfügbar.",
+ pageTitle: "Seite nicht gefunden",
+ },
footer: {
summary:
"Entwicklerwerkzeuge und Dateninfrastruktur auf der Grundlage beständiger Verträge.",
@@ -689,6 +699,11 @@ export const messages = {
dark: "Тёмная",
language: "Язык",
},
+ notFound: {
+ title: "К сожалению, запрошенная страница не найдена.",
+ text: "Возможно, адрес написан с ошибкой или страница, которую вы ищете, больше недоступна.",
+ pageTitle: "Страница не найдена",
+ },
footer: {
summary:
"Инструменты разработчика и инфраструктура данных, построенные на надёжных контрактах.",
@@ -953,6 +968,11 @@ export const messages = {
dark: "כהה",
language: "שפה",
},
+ notFound: {
+ title: "מצטערים, הדף שביקשת לא נמצא.",
+ text: "ייתכן שהכתובת שגויה, או שהדף שחיפשת כבר אינו זמין.",
+ pageTitle: "הדף לא נמצא",
+ },
footer: {
summary: "כלי פיתוח ותשתית נתונים, הבנויים על חוזים יציבים.",
products: "מוצרים",