All checks were successful
PR checks / checks (pull_request) Successful in 9m9s
PLAN.md §7: swapping a logo or recolouring the site is a file copy and a container restart, never a rebuild. Phase 2 builds the mechanism and the checks that keep it true. GET /brand/* resolves every file against the mount first and the baked-in defaults second, per file, at stable unhashed URLs with an ETag and a five minute TTL. Nothing goes through Vite, which would fingerprint the names out of the mount's reach. An X-Brand-Source header says which step answered. Three decisions were taken with the org lead (recorded as D14-D16 in §7): D14 — one raster in, every size out. brand-default holds a single logo.png; the header mark at three pixel ratios, both install icons, the apple-touch icon, the favicons and a real multi-resolution favicon.ico are derived on request from whichever logo.png is in force, cached, and limited to an allowlist of sizes. Shipping fifteen precomputed files would have meant an operator producing fifteen to change a mark — and getting a new header with the old favicon. D15 — brand text is applied at boot. Pages are prerendered, so §7's promise about the site name, tagline and links could not hold at render time. npm start now runs scripts/applyBrand.mjs first, rewriting the built HTML from what it last applied to what the mount says. It rewrites from a record in dist/.brand-applied.json rather than from the defaults, because the naive version works exactly once and then silently ignores every later edit. An empty mount is a no-op; removing a mount restores the stock build byte for byte. Verified both ways, plus a second rename. D16 — the header shows the real emblem, replacing phase 1's placeholder glyph, so the site, the product and the Android launcher icon are one mark. It is raster art, so theme.css cannot recolour it; replacing logo.png is how the mark changes. Two defects found and fixed while proving it: The mounted theme.css did not win. Astro emits its own stylesheet after the head markup, so linking the operator's last was not enough and every override was silently a no-op. tokens.css now lives in @layer tokens and the mounted file is unlayered, which takes order out of the mechanism entirely. The documentation was a different site. Starlight builds its own head, so the docs linked a Starlight default /favicon.svg that does not exist here, carried no manifest or OG card, and never loaded the brand stylesheet — a mounted theme recoloured the marketing pages and left the docs stock. A Head override fixes it; half a rebrand looks like a product bug rather than a missed step. brand-default/wordmark.svg and og-image.png are generated by scripts/buildBrandAssets.mjs from the emblem and Cinzel's outlines and are committed, so CI needs neither the artwork nor a font. Type is converted to paths, because an SVG in an <img> can see neither the page's @font-face rules nor fontconfig — the same isolation that broke currentColor in phase 1. Its glyphs are drawn at the origin and translated: opentype.js emits NaN coordinates at a non-zero origin for some glyphs, and a path parser stops at the first malformed command, so the first lockup read "Runic Gate" and looked like a typo rather than a bug. scripts/checkBrand.mjs is the mechanism for the two failures that are otherwise silent: it puts every literal /brand/... URL in the source through the route's own classifier, so a size that is not on the allowlist fails the build instead of 404ing in a browser, and it rejects a brand string short enough that a blind replacement at boot could corrupt a page. Negative-tested three ways before being trusted. It runs in CI ahead of the type check. Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import type { APIRoute } from 'astro';
|
|
|
|
import { brand } from '../lib/brand.mjs';
|
|
import { token } from '../lib/tokens.mjs';
|
|
|
|
/**
|
|
* The web app manifest.
|
|
*
|
|
* It exists because §7's table lists `icon-192.png` and `icon-512.png` as brand files, and
|
|
* without a manifest nothing ever asks for them — an installed-icon size that no document
|
|
* references is a file the operator maintains for nobody.
|
|
*
|
|
* Prerendered like every other page: the icon URLs it points at are stable and unhashed, so
|
|
* the manifest does not change when the icons behind them do. The two strings that CAN
|
|
* change — the name and the description — are handled the same way as the HTML, by
|
|
* `scripts/applyBrand.mjs` at boot, which is why that script rewrites `.webmanifest` as
|
|
* well as `.html`.
|
|
*/
|
|
export const GET: APIRoute = () =>
|
|
new Response(
|
|
JSON.stringify(
|
|
{
|
|
name: brand.siteName,
|
|
short_name: brand.siteName,
|
|
description: brand.tagline,
|
|
start_url: '/',
|
|
scope: '/',
|
|
display: 'standalone',
|
|
background_color: token('--bg'),
|
|
theme_color: token('--bg'),
|
|
icons: [
|
|
{ src: '/brand/icon-192.png', sizes: '192x192', type: 'image/png' },
|
|
{ src: '/brand/icon-512.png', sizes: '512x512', type: 'image/png' },
|
|
// `purpose: maskable` is a promise that the mark survives being cropped to a
|
|
// circle or a squircle. `buildBrandAssets.mjs` insets the emblem inside its
|
|
// canvas for exactly this, but the promise is only true for the STOCK logo — an
|
|
// operator who mounts edge-to-edge artwork would get it clipped on Android, so
|
|
// the declaration stays off until the site can know what it is shipping.
|
|
],
|
|
},
|
|
null,
|
|
2
|
|
),
|
|
{ headers: { 'Content-Type': 'application/manifest+json; charset=utf-8' } }
|
|
);
|