Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940// Bundled copies of the shared web fonts (source: web/static/fonts). They are// NOT committed (they come from the monorepo's canonical font assets) and are// NOT deployed as static assets (the assets upload skips gitignored files);// instead wrangler bundles them via the `Data` rule for **/*.woff2 and the// worker serves them at /static/fonts/<name>.import InterVariable from '../static/fonts/InterVariable.woff2';import InterVariableItalic from '../static/fonts/InterVariable-Italic.woff2';import InterDisplayBold from '../static/fonts/InterDisplay-Bold.woff2';import InterDisplayBoldItalic from '../static/fonts/InterDisplay-BoldItalic.woff2';import IBMPlexMonoRegular from '../static/fonts/IBMPlexMono-Regular.woff2';import IBMPlexMonoItalic from '../static/fonts/IBMPlexMono-Italic.woff2';import IBMPlexMonoBold from '../static/fonts/IBMPlexMono-Bold.woff2';import IBMPlexMonoBoldItalic from '../static/fonts/IBMPlexMono-BoldItalic.woff2';
const FONT_MAP: Record<string, ArrayBuffer> = { 'InterVariable.woff2': InterVariable, 'InterVariable-Italic.woff2': InterVariableItalic, 'InterDisplay-Bold.woff2': InterDisplayBold, 'InterDisplay-BoldItalic.woff2': InterDisplayBoldItalic, 'IBMPlexMono-Regular.woff2': IBMPlexMonoRegular, 'IBMPlexMono-Italic.woff2': IBMPlexMonoItalic, 'IBMPlexMono-Bold.woff2': IBMPlexMonoBold, 'IBMPlexMono-BoldItalic.woff2': IBMPlexMonoBoldItalic,};
/** Serves a bundled font for a `/static/fonts/<name>` URL path, or null. */export function serveFont(pathname: string): Response | null { const name = pathname.slice('/static/fonts/'.length); // Own-property lookup: Object.prototype keys (toString, __proto__, ...) must // not resolve to truthy non-buffer values. if (!Object.hasOwn(FONT_MAP, name)) return null; return new Response(FONT_MAP[name], { headers: { 'content-type': 'font/woff2', // Unversioned URLs: bounded TTL instead of a year-long immutable cache // so updated bundles are picked up within a day. 'cache-control': 'public, max-age=86400', }, });}