From 6718f1b033b63432ebedc907f36c0d8c43971758 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sat, 9 May 2026 23:47:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20updates=20page=20sorting=20=E2=80=94=20c?= =?UTF-8?q?orrect=20version=20typo=20971=E2=86=9297.1=20and=20add=20semver?= =?UTF-8?q?=20tiebreaker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...26.0.971.md => 2026-05-09-v2026.0.97.1.md} | 2 +- lib/updates.ts | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) rename content/updates/{2026-05-09-v2026.0.971.md => 2026-05-09-v2026.0.97.1.md} (97%) diff --git a/content/updates/2026-05-09-v2026.0.971.md b/content/updates/2026-05-09-v2026.0.97.1.md similarity index 97% rename from content/updates/2026-05-09-v2026.0.971.md rename to content/updates/2026-05-09-v2026.0.97.1.md index 43605a1..67dde09 100644 --- a/content/updates/2026-05-09-v2026.0.971.md +++ b/content/updates/2026-05-09-v2026.0.97.1.md @@ -1,7 +1,7 @@ --- title: "Submit Bug Fix & Game Card Layout Fix" date: "2026-05-09" -version: "2026.0.971" +version: "2026.0.97.1" summary: "Fixed submit wizard crash when creating new game versions and game card height issue in grid views." --- diff --git a/lib/updates.ts b/lib/updates.ts index 743997e..2971963 100644 --- a/lib/updates.ts +++ b/lib/updates.ts @@ -37,16 +37,30 @@ function getSlugs(): string[] { .map((file) => file.replace(/\.md$/, "")) } +function compareVersion(a: string, b: string): number { + const pa = a.split(".").map(Number) + const pb = b.split(".").map(Number) + const len = Math.max(pa.length, pb.length) + for (let i = 0; i < len; i++) { + const na = pa[i] ?? 0 + const nb = pb[i] ?? 0 + if (na !== nb) return nb - na // descending + } + return 0 +} + export function getAllUpdates(): UpdateMeta[] { const slugs = getSlugs() const updates = slugs.map((slug) => { const { meta } = getUpdateMeta(slug) return meta }) - // Sort by date descending (newest first) - return updates.sort( - (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(), - ) + // Sort by date descending, then by version descending (newest first) + return updates.sort((a, b) => { + const dateDiff = new Date(b.date).getTime() - new Date(a.date).getTime() + if (dateDiff !== 0) return dateDiff + return compareVersion(a.version, b.version) + }) } function getUpdateMeta(slug: string): { meta: UpdateMeta } {