Files
CatoandClaude Opus 5.5 583df713e1 refactor(site): the address lives in lib/site.ts only (#131)
Five files typed the host themselves (BYOK referer, two user agents, a
diagram caption, metadataBase). They now read SITE.host / SITE.url, so the
move to substrata.ch is a one-line change. Guarded by one-site-host.test.ts
(mutation-checked). No behaviour change.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 05:07:00 -07:00

47 lines
1.6 KiB
TypeScript

/**
* Substrata's own identity and link helper.
*
* Replaces what the renderers used to import from OrangeCat (`siteHref`,
* `siteCanonicalHost`, a `HostedSite` record). Substrata is not hosted inside
* another application any more, so a link is just a path and the canonical host
* is a constant.
*/
export const SITE = {
name: 'Substrata',
host: 'substrata.orangecat.ch',
/** Absolute origin, for anything that leaves the site (user agents, exports, referers). */
url: 'https://substrata.orangecat.ch',
repo: 'https://github.com/bitbaum/substrata',
} as const;
/**
* The correction intake: a prefilled public issue, no account on this site.
* "Being told when a row is wrong by someone who works in that chain" is the
* stated reason the research is free, so the route to tell us has to be one
* click and cannot ask for anything first.
*/
export function correctionUrl(
about: string,
known?: { problem?: string; source?: string },
): string {
const params = new URLSearchParams({
title: `Correction: ${about}`,
labels: 'correction',
body: [
'**Which row** (material and company, or the page and section):',
known ? about : '',
'**What is wrong**:',
known?.problem ?? '',
'**Source** (a link that shows it — the row cannot change without one):',
known?.source ?? '',
].join('\n'),
});
return `${SITE.repo}/issues/new?${params.toString()}`;
}
/** An in-site link. Root is '/', everything else '/segment'. */
export function href(path = ''): string {
const clean = path.replace(/^\/+|\/+$/g, '');
return clean ? `/${clean}` : '/';
}