feat: default-sort the website table by downloads per month

Entries with a download count now sort first (descending), with
stars, then Built-in, then name as fallback tiers for entries that
lack a count. main.js mirrors this in its default activeSort, clean
URL check, and third-click reset target. Sorting by stars remains one
header click away.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen 2026-08-16 19:15:21 +08:00
parent b841db68ba
commit d3fec1f7fa
No known key found for this signature in database
GPG key ID: B93DE4F003C33630
3 changed files with 14 additions and 8 deletions

View file

@ -5,7 +5,7 @@ function getScrollBehavior() {
}
let activeFilter = null;
let activeSort = { col: "stars", order: "desc" };
let activeSort = { col: "downloads", order: "desc" };
const searchInput = document.querySelector(".search");
const filterBar = document.querySelector(".filter-bar");
const filterValue = document.querySelector(".filter-value");
@ -211,7 +211,7 @@ function buildQueryString() {
const params = new URLSearchParams();
const query = searchInput ? searchInput.value.trim() : "";
if (query) params.set("q", query);
if (activeSort.col !== "stars" || activeSort.order !== "desc") {
if (activeSort.col !== "downloads" || activeSort.order !== "desc") {
params.set("sort", activeSort.col);
params.set("order", activeSort.order);
}
@ -392,7 +392,7 @@ sortHeaders.forEach(function (th) {
if (activeSort.col === col) {
if (activeSort.order === defaultOrder)
activeSort = { col: col, order: altOrder };
else activeSort = { col: "stars", order: "desc" };
else activeSort = { col: "downloads", order: "desc" };
} else {
activeSort = { col: col, order: defaultOrder };
}