From 82dff3fa86ecf94c35c3e1adad8288ea5f48ed9a Mon Sep 17 00:00:00 2001 From: tianma-if Date: Tue, 29 Sep 2026 09:05:42 +0800 Subject: [PATCH] fix(site): align star count formatting with GitHub official rounding --- apps/site/src/components/hero.astro | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/site/src/components/hero.astro b/apps/site/src/components/hero.astro index 7619be10..ebf7e1cf 100644 --- a/apps/site/src/components/hero.astro +++ b/apps/site/src/components/hero.astro @@ -209,10 +209,17 @@ const copy = siteCopy[locale].hero; (function () { function formatCount(count) { if (typeof count !== "number") return String(count); - if (count >= 1000) { - return (count / 1000).toFixed(1).replace(/\.0$/, "") + "k"; + try { + return new Intl.NumberFormat("en", { + notation: "compact", + maximumFractionDigits: 1, + }).format(count).toLowerCase(); + } catch (e) { + if (count >= 1000) { + return (Math.round(count / 100) / 10).toFixed(1).replace(/\.0$/, "") + "k"; + } + return count.toLocaleString(); } - return count.toLocaleString(); } async function fetchGitHubStats() {