fix(site): align star count formatting with GitHub official rounding

This commit is contained in:
tianma-if committed 2026-09-29 09:05:42 +08:00
1 parent 44eb0a2322
commit 82dff3fa86
1 file changed
+10 -3
+10 -3
View File
@@ -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() {