fix(site): align star count formatting with GitHub official rounding
This commit is contained in:
1 parent
44eb0a2322
commit
82dff3fa86
1 file changed
+10
-3
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user