diff options
| author | Leitwolf11 | 2026-11-17 15:12:16 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-17 15:12:16 +0300 |
| commit | 0036d3f1348f13dda83f97cba8a0a135abe5a7da (patch) | |
| tree | 6e29aa1a79b993b31409050b4bdff34dc12414b0 /apps/web/app | |
| parent | 477625cd75db2295d0f05bce206d9ea1b5b13ef2 (diff) | |
| download | progmaweb-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/web/app')
| -rw-r--r-- | apps/web/app/not-found.tsx | 36 | ||||
| -rw-r--r-- | apps/web/app/products/[slug]/page.tsx | 11 | ||||
| -rw-r--r-- | apps/web/app/site.css | 23 |
3 files changed, 67 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); +} |