From 64d9c6db17c4de22ed7dcc100f2d49cd62ebf142 Mon Sep 17 00:00:00 2001 From: Arindam Choudhury Date: Thu, 5 Nov 2026 16:16:49 -0500 Subject: [PATCH] Gallery: sort by newest by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Newest (by createdAt) is now the first sort option and the default; Recently updated and Title A–Z stay available. The URL omits ?sort= for the default, and the no-JavaScript list uses the same order. --- site/build.mjs | 5 +++-- site/src/app.js | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/site/build.mjs b/site/build.mjs index add8466..629f768 100644 --- a/site/build.mjs +++ b/site/build.mjs @@ -210,7 +210,8 @@ function readItems() { if (!subHue.has(i.subcategory)) subHue.set(i.subcategory, SUB_HUES[subHue.size % SUB_HUES.length]); } for (const i of items) i.hue = subHue.get(i.subcategory); - return items.sort((a, b) => (b.updatedAt ?? "").localeCompare(a.updatedAt ?? "") || a.name.localeCompare(b.name)); + // Newest first, matching the gallery's default sort. + return items.sort((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? "") || a.name.localeCompare(b.name)); } // ---------- page shell ---------- @@ -325,7 +326,7 @@ function indexPage(items, catalog) { ${select("category", "Category", "All categories", categoryOrder, byCategory)} ${select("subcategory", "Sub-category", "All sub-categories", sortedKeys(bySub), bySub)} ${select("platform", "Platform", "All platforms", sortedKeys(byPlatform), byPlatform)} - +
diff --git a/site/src/app.js b/site/src/app.js index a19b74a..36ceada 100644 --- a/site/src/app.js +++ b/site/src/app.js @@ -25,14 +25,14 @@ const v = p.get(k); if (v !== null) els[k].value = v; } - if (!els.sort.value) els.sort.value = "updated"; + if (!els.sort.value) els.sort.value = "newest"; } function writeState() { const p = new URLSearchParams(); for (const k of Object.keys(els)) { const v = els[k].value.trim(); - if (v && !(k === "sort" && v === "updated")) p.set(k, v); + if (v && !(k === "sort" && v === "newest")) p.set(k, v); } const qs = p.toString(); history.replaceState(null, "", qs ? `?${qs}#gallery` : location.pathname + (location.hash || "")); @@ -83,7 +83,7 @@ } function isFiltered() { - return Object.keys(els).some((k) => (k === "sort" ? els.sort.value !== "updated" : els[k].value.trim() !== "")); + return Object.keys(els).some((k) => (k === "sort" ? els.sort.value !== "newest" : els[k].value.trim() !== "")); } // Cards in a row share the tallest card's height, so a card with a short title has @@ -110,7 +110,7 @@ } function clear() { - for (const k of Object.keys(els)) els[k].value = k === "sort" ? "updated" : ""; + for (const k of Object.keys(els)) els[k].value = k === "sort" ? "newest" : ""; render(); els.q.focus(); }