Merge pull request #1708 from rdbtCVS/t3/7c6098f0

Website: unify navigation across Home, Releases, Benchmarks and Docs
This commit is contained in:
Ludovic Marie
2026-10-25 14:21:12 +01:00
committed by GitHub
9 changed files with 50 additions and 105 deletions
+4
View File
@@ -10,6 +10,9 @@ stone texture and a pixel landscape drawn in code (`scripts/art.mjs`), and short
releases, the community links and the contributors. Plain HTML, CSS and JavaScript; no framework and
no runtime dependencies.
Home, Releases, Benchmarks and every Docs page share the header and phone menu rendered by
`build.mjs`, with the same links, theme switch and Download button.
## Layout
```
@@ -29,6 +32,7 @@ src/main.js the home page: download buttons, recent releases, links, cont
src/chrome.js the light/dark switch, the phone menu and GitHub fetching, shared by the pages
src/releases-page.js the Releases page: the channel filter and the refresh from GitHub
src/benchmarks-page.js the Benchmarks page: players' results from the telemetry server, the picker
src/docs-page.js the Docs pages: the shared theme switch and phone menu
src/bench.js the Benchmarks tables, shared by build and page
src/hardware.js the spec table estimates use (GPU TFLOPS and bandwidth, CPU single-thread score)
src/estimate.js estimates for unmeasured hardware from the nearest measured machine
+13 -9
View File
@@ -170,7 +170,7 @@ await writeFile(join(dist, "favicon.ico"), Buffer.concat([ico, png32]));
const names = {};
const rewrite = (code) => code.replace(/"\.\/(\w+\.js)"/g, (all, file) => (names[file] ? `"./${names[file]}"` : all));
// Dependencies before what imports them.
const modules = ["markdown.js", "versions.js", "chrome.js", "hardware.js", "estimate.js", "releases.js", "contributors.js", "bench.js", "main.js", "releases-page.js", "benchmarks-page.js"];
const modules = ["markdown.js", "versions.js", "chrome.js", "hardware.js", "estimate.js", "releases.js", "contributors.js", "bench.js", "main.js", "releases-page.js", "benchmarks-page.js", "docs-page.js"];
for (const file of modules) {
const code = rewrite(await readFile(join(site, "src", file), "utf8"));
names[file] = `${file.replace(".js", "")}.${fingerprint(code)}.js`;
@@ -201,13 +201,16 @@ const baked = {
const unavailable = `<p class="lede">The release notes could not be loaded here.</p><a class="button secondary" href="https://github.com/${REPO}/releases">Read them on GitHub</a>`;
// The top bar and the footer of the pages beside the home page (Releases, Benchmarks).
const navLinks = [["/#about", "About"], ["/releases", "Releases"], ["/benchmarks", "Benchmarks"], ["/docs/", "Docs"]];
const siteNav = (current) => ` <header class="nav is-scrolled" id="top">
// One top bar and phone menu for Home, Releases, Benchmarks and every Docs page.
const navSections = [["/#about", "About"], ["/#screenshots", "In game"], ["/#parity", "Parity"], ["/#launcher", "Launcher"], ["/#recent", "New", "Recently added"], ["/#community", "Community"]];
const navPages = [["/releases", "Releases"], ["/benchmarks", "Benchmarks"], ["/docs/", "Docs", "Documentation"]];
const navLink = ([href, label, menuLabel], current, menu = false) =>
`<a href="${href}"${href === current ? ' aria-current="page"' : ""}${href === "/#contributors" ? ` data-contributors${contributors.length ? "" : " hidden"}` : ""}>${menu && menuLabel ? menuLabel : label}</a>`;
const siteNav = (current) => ` <header class="nav" id="top">
<div class="nav-inner">
<a class="nav-mark" href="/" aria-label="Horizon, home"><svg class="mark" viewBox="0 0 16 16" aria-hidden="true"><path class="mark-stem" d="M4 3h2v4H4zM10 3h2v4h-2z"/><path class="mark-low" d="M4 8h2v4H4zM10 8h2v4h-2z"/><path class="mark-line" d="M1 7h14v1H1z"/></svg>Horizon</a>
<nav class="nav-links" aria-label="Pages">
${navLinks.map(([href, label]) => ` <a href="${href}"${href === current ? ' aria-current="page"' : ""}>${label}</a>`).join("\n")}
<nav class="nav-links" id="nav-links" aria-label="Sections and pages">
${[...navSections, ...navPages].map((link) => ` ${navLink(link, current)}`).join("\n")}
</nav>
<div class="nav-end">
<button class="theme-toggle" type="button" aria-label="Switch between light and dark"><span data-theme-label>Dark</span></button>
@@ -218,9 +221,8 @@ ${navLinks.map(([href, label]) => ` <a href="${href}"${href === current
</div>
</header>
<div class="menu" id="menu" hidden>
<nav aria-label="Pages">
<a href="/">Home</a>
${navLinks.map(([href, label]) => ` <a href="${href}">${label}</a>`).join("\n")}
<nav aria-label="Sections and pages">
${[...navSections, ["/#contributors", "Contributors"], ...navPages].map((link) => ` ${navLink(link, current, true)}`).join("\n")}
</nav>
<div class="menu-foot">
<a class="button secondary large" href="https://github.com/${REPO}">GitHub</a>
@@ -261,6 +263,7 @@ const values = {
RECENT: recentHtml(game) || unavailable,
SITE_NAV: "",
SITE_FOOTER: siteFooter,
DOCS_JS: `/assets/${names["docs-page.js"]}`,
RELEASES_JS: `/assets/${names["releases-page.js"]}`,
RELEASE_LIST: releasesPageHtml(ours) || unavailable,
RELEASE_COUNT: ours.length ? `${ours.length} releases` : "",
@@ -350,6 +353,7 @@ const docPages = renderedDocs.map((d, i) => {
DOC_BODY: d.html,
DOC_PAGER: pagerLink(renderedDocs[i - 1], "prev") + pagerLink(renderedDocs[i + 1], "next"),
DOC_FILE: d.file,
SITE_NAV: siteNav("/docs/"),
},
};
});
-3
View File
@@ -39,9 +39,6 @@ for (const [width, height] of sizes) {
scrollTo({ top: 0, behavior: "instant" });
});
await page.waitForTimeout(800);
// A full-page capture draws the fixed bar once, at the top, over the hero: show it as the
// hero sees it, not in its scrolled state.
await page.evaluate(() => document.querySelector(".nav").classList.remove("is-scrolled"));
const report = await page.evaluate((touch) => {
const out = [];
const doc = document.documentElement;
+4 -4
View File
@@ -1,5 +1,5 @@
// What every page with the site's top bar shares: the light and dark switch and the phone menu.
// Used by main.js (the home page) and page.js (Releases, Benchmarks).
// Used by Home, Releases, Benchmarks and Docs.
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
// The page follows the system; the toggle picks the other appearance and remembers it.
@@ -27,7 +27,7 @@ export function setUpMenu() {
const bar = document.querySelector(".nav");
const button = document.querySelector(".menu-button");
const menu = document.getElementById("menu");
const main = document.getElementById("main");
const content = document.querySelector("[data-menu-content]") || document.getElementById("main");
if (!bar || !button || !menu) return;
const label = button.querySelector(".menu-label");
const items = [...menu.querySelectorAll("nav a")];
@@ -38,7 +38,7 @@ export function setUpMenu() {
button.setAttribute("aria-expanded", String(open));
label.textContent = open ? "Close" : "Menu";
bar.classList.toggle("is-menu", open);
main.inert = open;
content.inert = open;
document.body.style.overflow = open ? "hidden" : "";
if (open) {
menu.hidden = false;
@@ -57,7 +57,7 @@ export function setUpMenu() {
button.focus();
}
});
matchMedia("(min-width: 1120px)").addEventListener("change", (e) => e.matches && setOpen(false));
matchMedia("(min-width: 1280px)").addEventListener("change", (e) => e.matches && setOpen(false));
}
// GitHub answers, cached for ten minutes in the tab.
+5
View File
@@ -0,0 +1,5 @@
// The Docs pages share the site's theme switch and phone menu.
import { setUpMenu, setUpTheme } from "./chrome.js";
setUpTheme();
setUpMenu();
+6 -14
View File
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="en">
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>{{DOC_TITLE}} · Horizon docs</title>
<meta name="description" content="{{DOC_DESC}}">
<meta name="theme-color" content="#ece7f7" media="(prefers-color-scheme: light)">
@@ -19,22 +19,14 @@
<meta property="og:url" content="https://playhorizon.dev{{DOC_PATH}}">
<meta property="og:image" content="https://playhorizon.dev/og.png">
<link rel="stylesheet" href="{{CSS}}">
<script>try { const t = localStorage.getItem("theme"); if (t === "light" || t === "dark") document.documentElement.dataset.theme = t } catch {}</script>
<script>document.documentElement.classList.replace("no-js", "js"); try { const t = localStorage.getItem("theme"); if (t === "light" || t === "dark") document.documentElement.dataset.theme = t } catch {}</script>
<script type="module" src="{{DOCS_JS}}"></script>
</head>
<body class="docs-page">
<a class="skip" href="#main">Skip to the content</a>
<header class="docs-bar">
<div class="docs-bar-inner">
<a class="nav-mark" href="/" aria-label="Horizon, home"><svg class="mark" viewBox="0 0 16 16" aria-hidden="true"><path class="mark-stem" d="M4 3h2v4H4zM10 3h2v4h-2z"/><path class="mark-low" d="M4 8h2v4H4zM10 8h2v4h-2z"/><path class="mark-line" d="M1 7h14v1H1z"/></svg>Horizon</a>
<a class="docs-bar-title" href="/docs/">Docs</a>
<span class="docs-bar-end">
<a class="docs-bar-link" href="https://github.com/ludovic111/horizon">GitHub</a>
<a class="button primary small" href="/docs/install">Download</a>
</span>
</div>
</header>
{{SITE_NAV}}
<div class="docs">
<div class="docs" data-menu-content>
<details class="docs-nav-wrap" open>
<summary>Docs menu</summary>
<nav class="docs-nav" aria-label="Documentation">
+1 -41
View File
@@ -35,47 +35,7 @@
<body>
<a class="skip" href="#main">Skip to the content</a>
<header class="nav" id="top">
<div class="nav-inner">
<a class="nav-mark" href="#top" aria-label="Horizon, back to the top"><svg class="mark" viewBox="0 0 16 16" aria-hidden="true"><path class="mark-stem" d="M4 3h2v4H4zM10 3h2v4h-2z"/><path class="mark-low" d="M4 8h2v4H4zM10 8h2v4h-2z"/><path class="mark-line" d="M1 7h14v1H1z"/></svg>Horizon</a>
<nav class="nav-links" id="nav-links" aria-label="Sections">
<a href="#about">About</a>
<a href="#screenshots">In game</a>
<a href="#parity">Parity</a>
<a href="#launcher">Launcher</a>
<a href="#recent">New</a>
<a href="#community">Community</a>
<a href="/releases">Releases</a>
<a href="/benchmarks">Benchmarks</a>
<a href="/docs/">Docs</a>
</nav>
<div class="nav-end">
<button class="theme-toggle" type="button" aria-label="Switch between light and dark"><span data-theme-label>Dark</span></button>
<a class="nav-github" href="https://github.com/ludovic111/horizon">GitHub</a>
<a class="button primary small" data-download href="https://github.com/ludovic111/horizon/releases?q=launcher-v&amp;expanded=true">Download</a>
<button class="menu-button" type="button" aria-expanded="false" aria-controls="menu"><span class="menu-label">Menu</span><span class="menu-icon" aria-hidden="true"></span></button>
</div>
</div>
</header>
<div class="menu" id="menu" hidden>
<nav aria-label="Sections">
<a href="#about">About</a>
<a href="#screenshots">In game</a>
<a href="#parity">Parity</a>
<a href="#launcher">Launcher</a>
<a href="#recent">Recently added</a>
<a href="#community">Community</a>
<a href="#contributors" data-contributors{{CONTRIBUTORS_HIDDEN}}>Contributors</a>
<a href="/releases">Releases</a>
<a href="/benchmarks">Benchmarks</a>
<a href="/docs/">Documentation</a>
</nav>
<div class="menu-foot">
<a class="button secondary large" href="https://github.com/ludovic111/horizon">GitHub</a>
<p>Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.</p>
</div>
</div>
{{SITE_NAV}}
<main id="main">
<section class="hero" aria-labelledby="hero-title">
+3 -5
View File
@@ -135,14 +135,12 @@ async function setUpLive() {
// --- Navigation ----------------------------------------------------------------------
function setUpNav() {
const bar = document.querySelector(".nav");
// The sections on this page (the nav also links to other pages, such as /server).
const links = [...document.querySelectorAll('.nav-links a[href^="#"]')];
const sections = links.map((a) => document.querySelector(a.getAttribute("href")));
// The home sections use the same root-relative links in every page's header.
const links = [...document.querySelectorAll('.nav-links a[href^="/#"]')];
const sections = links.map((a) => document.querySelector(a.hash));
let current = null;
const update = () => {
bar.classList.toggle("is-scrolled", scrollY > 24);
const line = innerHeight * 0.4;
let index = -1;
sections.forEach((s, i) => {
+14 -29
View File
@@ -117,14 +117,11 @@ code {
/* --- Navigation ------------------------------------------------------------------------- */
.nav {
position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav);
background: color-mix(in srgb, var(--page) 0%, transparent);
transition: background-color var(--move) var(--ease-move), box-shadow var(--move) var(--ease-move);
}
.nav.is-scrolled, .nav.is-menu {
position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav); max-width: 100vw;
background: color-mix(in srgb, var(--page) 88%, transparent);
-webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
box-shadow: 0 1px 0 var(--rule);
transition: background-color var(--move) var(--ease-move), box-shadow var(--move) var(--ease-move);
}
.nav-inner { display: flex; align-items: center; gap: 24px; height: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--g); }
.nav-mark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; font-size: var(--text-label); }
@@ -133,7 +130,7 @@ code {
.mark-stem { fill: var(--ink); }
.mark-low { fill: var(--ink); opacity: 0.36; }
.mark-line { fill: var(--accent); }
.nav-links { display: flex; gap: 2px; margin-left: auto; }
.nav-links { display: flex; gap: 2px; margin-left: auto; white-space: nowrap; }
.nav-links a, .nav-github, .theme-toggle {
display: inline-flex; align-items: center; height: 32px; padding: 0 12px;
border-radius: var(--radius-pill); color: var(--muted); font-size: var(--text-label);
@@ -162,12 +159,12 @@ code {
.is-menu .menu-icon::after { top: 4px; transform: rotate(-45deg); }
.menu {
position: fixed; inset: var(--nav) 0 0; z-index: 19; display: flex; flex-direction: column;
justify-content: space-between; padding: 24px var(--g) 32px; background: var(--page);
position: fixed; inset: var(--nav) 0 0; z-index: 19; display: flex; flex-direction: column; max-width: 100vw;
justify-content: space-between; gap: 24px; overflow-y: auto; padding: 24px var(--g) 32px; background: var(--page);
opacity: 0; transition: opacity var(--move) var(--ease-move);
}
.menu.is-open { opacity: 1; }
.menu nav { display: flex; flex-direction: column; }
.menu nav { display: flex; flex-direction: column; flex-shrink: 0; }
.menu nav a {
display: flex; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule);
color: var(--ink); font-size: var(--text-title); line-height: var(--text-title-line);
@@ -176,12 +173,13 @@ code {
transition: opacity var(--enter) var(--ease-enter), transform var(--enter) var(--ease-enter);
}
.menu.is-open nav a { opacity: 1; transform: none; }
.menu-foot { display: flex; flex-direction: column; gap: 16px; }
.menu-foot { display: flex; flex-direction: column; gap: 16px; flex-shrink: 0; }
.menu-foot p { font-size: var(--text-caption); color: var(--muted); }
@media (max-width: 1119px) {
@media (max-width: 1279px) {
.nav-links, .nav-github { display: none; }
.menu-button { display: inline-flex; }
.nav-end { margin-left: auto; }
}
@media (max-width: 520px) {
.nav-end .button { display: none; }
@@ -426,22 +424,11 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
/* --- Documentation (/docs): a left navigation and one page at a time --------------------- */
.docs-bar {
position: sticky; top: 0; z-index: 20; height: 56px;
background: color-mix(in srgb, var(--page) 88%, transparent);
-webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
box-shadow: 0 1px 0 var(--rule);
}
.docs-bar-inner { display: flex; align-items: center; gap: 16px; height: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--g); }
.docs-bar-title { padding-left: 16px; border-left: 1px solid var(--rule); color: var(--muted); font-size: var(--text-label); }
.docs-bar-end { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.docs-bar-link { color: var(--muted); font-size: var(--text-label); }
.docs-bar-link:hover { color: var(--ink); }
.docs {
display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: clamp(32px, 6vw, 96px);
max-width: var(--max); margin: 0 auto; padding: 48px var(--g) 0; align-items: start;
max-width: var(--max); margin: 0 auto; padding: calc(var(--nav) + 48px) var(--g) 0; align-items: start;
}
.docs-nav-wrap { position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow-y: auto; padding-bottom: 24px; }
.docs-nav-wrap { position: sticky; top: calc(var(--nav) + 24px); max-height: calc(100vh - var(--nav) - 48px); overflow-y: auto; padding-bottom: 24px; }
.docs-nav-wrap summary { display: none; }
.docs-nav-group { margin: 28px 0 8px; font: var(--text-micro) / var(--text-micro-line) var(--mono); letter-spacing: var(--text-micro-tracking); text-transform: uppercase; color: var(--muted); }
.docs-nav-group:first-child { margin-top: 0; }
@@ -478,7 +465,7 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
.docs-main .disclaimer { margin-top: 24px; }
@media (max-width: 900px) {
.docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 12px; }
.docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: calc(var(--nav) + 12px); }
.docs-nav-wrap { position: static; max-height: none; overflow: visible; margin-bottom: 24px; border-bottom: 1px solid var(--rule); }
.docs-nav-wrap summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 500; list-style: none; }
.docs-nav-wrap summary::-webkit-details-marker { display: none; }
@@ -486,10 +473,9 @@ figcaption span { font-family: var(--mono); font-size: var(--text-micro); letter
.docs-nav-wrap[open] summary::after { content: "\2212"; }
.docs-pager { grid-template-columns: minmax(0, 1fr); }
.docs-pager-next { grid-column: 1; }
.docs-bar-link { display: none; }
}
@media (pointer: coarse) {
.docs-nav li a, .docs-toc a, .docs-bar-title, .docs-bar-link { display: flex; align-items: center; min-height: 44px; }
.docs-nav li a, .docs-toc a { display: flex; align-items: center; min-height: 44px; }
}
/* --- Blocks: the launcher's look on the page (docs/design-system.md, "Blocks") -------------
@@ -548,7 +534,7 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
:focus-visible { border-radius: 0; }
/* The top bar: the sidebar colour with an outline under it, tabs with an accent underline. */
.nav.is-scrolled, .nav.is-menu { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
.nav { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
.nav-links a, .nav-github, .theme-toggle { border-radius: 0; font-family: var(--pixel); font-weight: 500; font-size: 15px; }
.nav-links a:hover, .nav-github:hover, .theme-toggle:hover { background: var(--raised); }
.nav-links a[aria-current] { background: var(--raised); box-shadow: inset 0 -3px 0 var(--accent); }
@@ -606,7 +592,6 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
}
/* Documentation. */
.docs-bar { background: var(--side); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 var(--block-outline) 0 var(--outline); }
.docs-nav li a { border-radius: 0; }
.docs-nav li a[aria-current] { background: var(--raised); box-shadow: inset 4px 0 0 var(--accent); }
.docs-toc a { border-radius: 0; background: var(--button); box-shadow: 0 0 0 var(--block-outline) var(--outline); }