Website: add a Contributors block to the community section

Lists the GitHub contributors of ludovic111/horizon (bots left out, the
owner first) with avatar, login, commit count and a link to the profile.
Built in by build.mjs like the releases (the build still succeeds when
GitHub does not answer, and the block stays hidden until the page loads
it) and refreshed by the page from the API. Adds a nav and menu entry,
lets avatars.githubusercontent.com through img-src, and updates the
README, LEGAL.md and the privacy note.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-14 02:01:43 +02:00
parent e5c061dba6
commit 2b7c72255c
8 changed files with 116 additions and 13 deletions
+39
View File
@@ -0,0 +1,39 @@
// The contributors: GitHub's list for the repository, without bots, the owner first. Shared by
// build.mjs (baked into the page) and main.js (refreshed from GitHub).
import { escape } from "./markdown.js";
const OWNER = "ludovic111";
const AVATARS = "https://avatars.githubusercontent.com/";
// Reduces GitHub's contributor objects to what the page shows; bots (type Bot, or a login
// ending in [bot]) and anything without a login or a profile address are dropped.
export function contributorsFrom(list) {
if (!Array.isArray(list)) return [];
return list
.filter((c) => c && typeof c.login === "string" && c.login && c.type !== "Bot" && !/\[bot\]$/i.test(c.login))
.map((c) => ({
login: c.login,
html_url: typeof c.html_url === "string" ? c.html_url : `https://github.com/${c.login}`,
avatar_url: typeof c.avatar_url === "string" ? c.avatar_url : "",
contributions: Number(c.contributions) || 0,
}))
.sort((a, b) => (b.login === OWNER) - (a.login === OWNER) || b.contributions - a.contributions);
}
// GitHub serves avatars at any size: 96 px is twice what the page draws, for sharp screens.
function avatar(url) {
if (!url.startsWith(AVATARS)) return "";
const u = new URL(url);
u.searchParams.set("s", "96");
return u.href;
}
export function contributorsHtml(list) {
return list
.map((c) => {
const src = avatar(c.avatar_url);
const count = `${c.contributions.toLocaleString("en-US")} ${c.contributions === 1 ? "commit" : "commits"}`;
return `<li><a class="contributor" href="${escape(c.html_url)}">${src ? `<img class="contributor-avatar" loading="lazy" decoding="async" src="${escape(src)}" width="48" height="48" alt="">` : `<span class="contributor-avatar" aria-hidden="true"></span>`}<span class="contributor-name">${escape(c.login)}</span><span class="contributor-count">${count}</span></a></li>`;
})
.join("");
}
+8 -1
View File
@@ -46,6 +46,7 @@
<a href="#patch-notes">Notes</a>
<a href="#next">Roadmap</a>
<a href="#community">Community</a>
<a href="#contributors" data-contributors{{CONTRIBUTORS_HIDDEN}}>Contributors</a>
</nav>
<div class="nav-end">
<a class="nav-github" href="https://github.com/ludovic111/horizon">GitHub</a>
@@ -64,6 +65,7 @@
<a href="#patch-notes">Patch notes</a>
<a href="#next">Roadmap</a>
<a href="#community">Community</a>
<a href="#contributors" data-contributors{{CONTRIBUTORS_HIDDEN}}>Contributors</a>
</nav>
<div class="menu-foot">
<a class="button secondary large" href="https://github.com/ludovic111/horizon">GitHub</a>
@@ -228,6 +230,11 @@
<a class="card reveal" data-card data-link="sponsor" href="{{SPONSOR}}"><span class="card-title">Sponsor</span><span class="card-text">Sponsors on GitHub fund the next release.</span><span class="card-arrow" aria-hidden="true">→</span></a>
<a class="card reveal" data-card href="https://github.com/ludovic111/horizon"><span class="card-title">Source</span><span class="card-text">Issues and pull requests are welcome.</span><span class="card-arrow" aria-hidden="true">→</span></a>
</div>
<div class="contributors" id="contributors" aria-labelledby="contributors-title" data-contributors{{CONTRIBUTORS_HIDDEN}}>
<h3 class="contributors-title reveal" id="contributors-title">Contributors</h3>
<p class="contributors-text reveal">Everyone who has committed to Horizon on GitHub, with how many commits.</p>
<ul class="contributors-list reveal" id="contributors-list">{{CONTRIBUTORS}}</ul>
</div>
</div>
</section>
</main>
@@ -238,7 +245,7 @@
<div class="footer-cols">
<p>Horizon is made by <a href="https://lu4ovic.com">Ludovic Marie</a>, who is responsible for it and for this site; reach him through <a href="https://lu4ovic.com/#contact">lu4ovic.com</a>. Horizon contains no Minecraft code, assets or data, and this site offers no game files: you need your own legally obtained copy of Minecraft: Java Edition. Minecraft is a trademark of Mojang Synergies AB.</p>
<p>Horizon's original work is under the <a href="https://github.com/ludovic111/horizon/blob/main/LICENSE">MIT licence</a>. The fonts are Geist and Instrument Serif, under the SIL Open Font License (<a href="/fonts/OFL-Geist.txt">Geist</a>, <a href="/fonts/OFL-InstrumentSerif.txt">Instrument Serif</a>). Every asset on this site is listed in <a href="/LEGAL.md">LEGAL.md</a>.</p>
<p>Privacy: this site sets no cookies, has no analytics or trackers and loads nothing from third parties except GitHub. To show the latest releases, patch notes, roadmap and links, your browser asks <code>api.github.com</code> and <code>raw.githubusercontent.com</code> for them; <a href="https://docs.github.com/site-policy/privacy-policies/github-general-privacy-statement">GitHub's privacy statement</a> covers those requests.</p>
<p>Privacy: this site sets no cookies, has no analytics or trackers and loads nothing from third parties except GitHub. To show the latest releases, patch notes, roadmap, links and contributors, your browser asks <code>api.github.com</code> and <code>raw.githubusercontent.com</code> for them, and <code>avatars.githubusercontent.com</code> for the contributors' pictures; <a href="https://docs.github.com/site-policy/privacy-policies/github-general-privacy-statement">GitHub's privacy statement</a> covers those requests.</p>
</div>
<div class="footer-bar">
<span class="footer-mark">Horizon</span>
+14 -2
View File
@@ -1,8 +1,9 @@
// The page's behaviour: the download buttons for this platform, the latest releases, the
// roadmap and links from main, the navigation, the menus' tabs, the lightbox and the motion.
// roadmap, links and contributors, the navigation, the menus' tabs, the lightbox and the motion.
// Everything degrades to the baked-in content when GitHub can't be reached.
import { markdown, escape, section } from "./markdown.js";
import { releasesHtml } from "./releases.js";
import { contributorsFrom, contributorsHtml } from "./contributors.js";
const REPO = "ludovic111/horizon";
const RELEASES_PAGE = `https://github.com/${REPO}/releases?q=launcher-v&expanded=true`;
@@ -46,6 +47,16 @@ const releases = cached("horizon:releases", () =>
),
).catch(() => baked.releases);
async function setUpContributors() {
let list = baked.contributors || [];
try {
list = contributorsFrom(await cached("horizon:contributors", () => get(`https://api.github.com/repos/${REPO}/contributors?per_page=100`)));
} catch {}
if (list.length) document.getElementById("contributors-list").innerHTML = contributorsHtml(list);
// With nobody to show, the block and its menu entries go, as an empty link's card does.
document.querySelectorAll("[data-contributors]").forEach((el) => (el.hidden = !list.length));
}
// --- Download ------------------------------------------------------------------------
function platform() {
@@ -119,7 +130,7 @@ function setUpNav() {
const line = innerHeight * 0.4;
let index = -1;
sections.forEach((s, i) => {
if (s.getBoundingClientRect().top <= line) index = i;
if (s.getClientRects().length && s.getBoundingClientRect().top <= line) index = i;
});
if (index !== current) {
current = index;
@@ -316,3 +327,4 @@ setUpDownload();
setUpNotes();
setUpRoadmap();
setUpLinks();
setUpContributors();
+18
View File
@@ -58,6 +58,7 @@ p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; transition: color var(--quick) var(--ease); }
a:hover { color: var(--text); }
[hidden] { display: none !important; }
/* Links inside running text are underlined, so they don't rely on colour alone. */
p a:not(.button):not(.link-arrow) { text-decoration: underline; text-decoration-color: rgba(164, 138, 230, 0.45); text-decoration-thickness: 1px; text-underline-offset: 3px; }
p a:not(.button):not(.link-arrow):hover { text-decoration-color: currentColor; }
@@ -561,6 +562,23 @@ code {
.card:hover .card-arrow { transform: translateX(6px); color: var(--accent-text); }
@media (min-width: 860px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.contributors { margin-top: clamp(64px, 8vw, 112px); }
.contributors-title { font: 400 clamp(28px, 3vw, 40px)/1.1 var(--display); letter-spacing: -0.015em; color: var(--text); }
.contributors-text { margin-top: 10px; font-size: 15px; color: var(--muted); max-width: 46ch; }
.contributors-list {
display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); column-gap: 32px;
list-style: none; margin-top: clamp(24px, 3vw, 36px); padding: 0;
}
.contributors-list li { border-top: 1px solid var(--border); }
.contributor {
display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 16px; align-items: center;
min-height: 44px; padding: 20px 0; color: var(--text);
}
.contributor-avatar { grid-row: 1 / 3; width: 48px; height: 48px; border-radius: 50%; background: var(--raised); border: 1px solid var(--border); object-fit: cover; }
.contributor-name { align-self: end; font-size: 16px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; transition: color var(--quick) var(--ease); }
.contributor-count { align-self: start; font: 12px/1.7 var(--mono); color: var(--faint); }
.contributor:hover .contributor-name { color: var(--accent-text); }
/* --- Footer ------------------------------------------------------------------------- */
.footer { margin-top: clamp(112px, 14vw, 200px); border-top: 1px solid var(--border); padding-top: clamp(64px, 8vw, 104px); overflow: hidden; }