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>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// 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/");
|
||||
@@ -0,0 +1,109 @@
|
||||
// Full-page screenshots of the built site at every width that matters, plus the social
|
||||
// preview image. Run `npm run build` first; `npm run shots` serves dist/ and writes
|
||||
// docs/widths/*.png (and 390-menu.png, the open menu) and public/og.png (rebuild after).
|
||||
// It also checks each width for horizontal scroll and small tap targets.
|
||||
import { chromium } from "playwright";
|
||||
import { spawn } from "node:child_process";
|
||||
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
||||
import sharp from "sharp";
|
||||
import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const site = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const port = 4199;
|
||||
const url = `http://localhost:${port}/`;
|
||||
const server = spawn(process.execPath, [join(site, "serve.mjs")], { env: { ...process.env, PORT: String(port) }, stdio: "ignore" });
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
|
||||
const widths = [360, 390, 430, 768, 1024, 1180, 1250, 1280, 1366, 1440, 1680, 1920];
|
||||
const sizes = [...widths.map((w) => [w, w < 900 ? 800 : 900]), [1250, 700]];
|
||||
const only = process.argv.slice(2);
|
||||
|
||||
await mkdir(join(site, "docs/widths"), { recursive: true });
|
||||
const browser = await chromium.launch();
|
||||
let problems = 0;
|
||||
|
||||
for (const [width, height] of sizes) {
|
||||
const name = height === 700 ? `${width}x${height}` : `${width}`;
|
||||
if (only.length && !only.includes(name)) continue;
|
||||
const touch = width < 900;
|
||||
const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 1, hasTouch: touch, isMobile: touch });
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
// Reveal every section, as scrolling would, and let the fades finish.
|
||||
await page.evaluate(async () => {
|
||||
for (let y = 0; y < document.body.scrollHeight; y += 400) {
|
||||
scrollTo({ top: y, behavior: "instant" });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
}
|
||||
scrollTo({ top: 0, behavior: "instant" });
|
||||
});
|
||||
await page.waitForTimeout(800);
|
||||
// A full-page capture draws fixed elements once, at the top; pin the sidebar to the whole
|
||||
// page so the picture shows what a reader sees at every scroll position.
|
||||
if (height !== 700 && !touch) {
|
||||
await page.addStyleTag({ content: `.sidebar { position: absolute; bottom: auto; height: ${await page.evaluate(() => document.documentElement.scrollHeight)}px; }` });
|
||||
}
|
||||
const report = await page.evaluate((touch) => {
|
||||
const out = [];
|
||||
const doc = document.documentElement;
|
||||
if (doc.scrollWidth > innerWidth) out.push(`horizontal scroll: ${doc.scrollWidth} > ${innerWidth}`);
|
||||
for (const el of document.querySelectorAll("body *")) {
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.width && r.right > innerWidth + 1 && !el.closest(".table-scroll, .lightbox, .sidebar:not(.is-open)")) {
|
||||
out.push(`overflows: ${el.tagName.toLowerCase()}.${el.className} right ${Math.round(r.right)}`);
|
||||
}
|
||||
}
|
||||
if (touch) {
|
||||
for (const el of document.querySelectorAll("a, button, summary")) {
|
||||
if (el.closest(".sidebar:not(.is-open), .lightbox, .skip") || el.closest(".prose, .footer p:not(.footer-links), .row dd:not(.row-action), .table-meta, .parity")) continue;
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.width && r.height < 44) out.push(`small target: ${el.textContent.trim().slice(0, 30)} (${Math.round(r.height)}px)`);
|
||||
}
|
||||
}
|
||||
// Characters per line of the longest running-text paragraphs.
|
||||
const lengths = [...document.querySelectorAll(".prose p, .lede, .section-lede, .footer p")]
|
||||
.filter((p) => p.textContent.length > 160)
|
||||
.map((p) => {
|
||||
const lh = parseFloat(getComputedStyle(p).lineHeight);
|
||||
const n = Math.round(p.textContent.length / Math.max(1, Math.round(p.getBoundingClientRect().height / lh)));
|
||||
return [n, `${p.parentElement.id || p.parentElement.className}>${p.className || p.tagName}`];
|
||||
})
|
||||
.sort((a, b) => a[0] - b[0]);
|
||||
const [lo, hi] = [lengths[0], lengths[lengths.length - 1]];
|
||||
out.push(`chars per line: ${lo[0]} (${lo[1]})–${hi[0]} (${hi[1]})`);
|
||||
return out.slice(0, 12);
|
||||
}, touch);
|
||||
const issues = report.filter((l) => !l.startsWith("chars"));
|
||||
problems += issues.length;
|
||||
console.log(`${name}: ${issues.length ? issues.join("; ") : "ok"} · ${report.find((l) => l.startsWith("chars"))}`);
|
||||
await page.screenshot({ path: join(site, `docs/widths/${name}.png`), fullPage: height !== 700 });
|
||||
if (width === 390) {
|
||||
await page.click(".menu-button");
|
||||
await page.waitForTimeout(700);
|
||||
await page.screenshot({ path: join(site, "docs/widths/390-menu.png") });
|
||||
}
|
||||
await page.close();
|
||||
}
|
||||
|
||||
if (!only.length || only.includes("og")) {
|
||||
const page = await browser.newPage({ viewport: { width: 1200, height: 630 } });
|
||||
await page.goto(`${url}og.html`, { waitUntil: "networkidle" });
|
||||
await page.waitForTimeout(700);
|
||||
await page.screenshot({ path: join(site, "public/og.png") });
|
||||
await page.close();
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
server.kill();
|
||||
|
||||
// Keep the committed screenshots small: losslessly recompressed (a palette loses the 1px dividers).
|
||||
for (const dir of ["docs/widths"]) {
|
||||
for (const file of (await readdir(join(site, dir))).filter((f) => f.endsWith(".png"))) {
|
||||
const path = join(site, dir, file);
|
||||
await writeFile(path, await sharp(await readFile(path)).png({ compressionLevel: 9, adaptiveFiltering: true }).toBuffer());
|
||||
}
|
||||
}
|
||||
if (problems) {
|
||||
console.log(`${problems} problems`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user