Files
horizon-airdef/website/scripts/assets.mjs
T
Ludovic Marie f53f198f03 Website: one static page in the launcher's design, for Railway
website/ holds Horizon's site: the horizon-theme tokens and bundled fonts, the
launcher's sidebar, rows, buttons and segmented control, over Horizon's own frozen
landscape. The parity table, harness count and roadmap are generated from the README
at build time; releases, patch notes, the roadmap and links.json are refreshed in the
browser from GitHub, with the build's copy as fallback. The download button picks the
newest launcher-v* asset for the visitor's OS.

Legal: the Minecraft disclaimer in the hero, footer and 404; no Minecraft logo or
wordmark; no game files; the launcher's background (licence unconfirmed) and the
screenshots showing it are left out; LEGAL.md lists every asset and its licence. No
cookies, analytics or third-party assets.

Railway: root directory website, Dockerfile (Node build, Caddy on $PORT with a strict
CSP). Checked with Playwright at 360-1920 px and 1250x700 (docs/widths/); Lighthouse
96/100/96/92 on mobile, 100/100/96/92 on desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:03:56 +02:00

70 lines
3.0 KiB
JavaScript

// Copies the launcher's fonts, background and the repo's screenshots into public/,
// converted for the web (woff2, webp in two widths). Run it after any of them change:
// `npm run assets`. Its output is committed, because Railway builds only website/.
import { mkdir, readFile, writeFile, copyFile } from "node:fs/promises";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import sharp from "sharp";
import wawoff2 from "wawoff2";
const site = join(dirname(fileURLToPath(import.meta.url)), "..");
const repo = join(site, "..");
const pub = join(site, "public");
const fonts = [
"Geist-Regular.ttf",
"Geist-Medium.ttf",
"Geist-SemiBold.ttf",
"GeistMono-Regular.ttf",
"InstrumentSerif-Regular.ttf",
];
// The launcher's screenshots are left out: they show its background, whose licence is
// unconfirmed (see LEGAL.md). [source, name]; every image becomes media/<name>.webp and media/<name>-800.webp.
export const images = [
["docs/media/sunset.jpg", "sunset"],
["docs/media/village.jpg", "village"],
["docs/media/survival.jpg", "survival"],
["docs/media/nether.jpg", "nether"],
["docs/media/night.jpg", "night"],
["docs/media/underwater.jpg", "underwater"],
["docs/media/menu-title.png", "menu-title"],
["docs/media/menu-worlds.png", "menu-worlds"],
["docs/media/menu-options.png", "menu-options"],
["docs/media/menu-pause.png", "menu-pause"],
];
await mkdir(join(pub, "fonts"), { recursive: true });
await mkdir(join(pub, "media"), { recursive: true });
for (const font of fonts) {
const ttf = await readFile(join(repo, "crates/horizon-theme/fonts", font));
await writeFile(join(pub, "fonts", font.replace(".ttf", ".woff2")), await wawoff2.compress(ttf));
}
for (const licence of ["OFL-Geist.txt", "OFL-InstrumentSerif.txt"]) {
await copyFile(join(repo, "crates/horizon-theme/fonts", licence), join(pub, "fonts", licence));
}
for (const [source, name] of images) {
const input = join(repo, source);
await sharp(input).resize({ width: 1600, withoutEnlargement: true }).webp({ quality: 82 }).toFile(join(pub, "media", `${name}.webp`));
await sharp(input).resize({ width: 800 }).webp({ quality: 78 }).toFile(join(pub, "media", `${name}-800.webp`));
}
// The atmosphere: the frozen landscape Horizon renders behind its own title screen, cut from
// the part of docs/media/menu-title.png that has no interface on it and blurred further.
// One file, so it can be replaced.
await sharp(join(repo, "docs/media/menu-title.png"))
.extract({ left: 600, top: 545, width: 1000, height: 400 })
.resize(1600, 900, { fit: "cover" })
.blur(10)
.webp({ quality: 78 })
.toFile(join(pub, "background.webp"));
// Icons from the project's logo.
await copyFile(join(repo, "docs/media/logo.svg"), join(pub, "favicon.svg"));
await sharp(join(repo, "docs/media/logo.svg")).resize(180).png().toFile(join(pub, "apple-touch-icon.png"));
await sharp(join(repo, "docs/media/logo.svg")).resize(32).png().toFile(join(pub, "favicon-32.png"));
console.log("assets written to public/");