mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-09 12:27:43 +00:00
docs: fix kformatter support for millions (#2574)
This commit is contained in:
committed by
GitHub
parent
6caf2a48ab
commit
3fdbe99cd5
@@ -52,7 +52,7 @@ export default function Stats({ npmDownloads }: { npmDownloads: number }) {
|
|||||||
<div className="flex pt-5 w-full dark:[box-shadow:0_-20px_80px_-20px_#dfbf9f1f_inset] flex-col items-center justify-between">
|
<div className="flex pt-5 w-full dark:[box-shadow:0_-20px_80px_-20px_#dfbf9f1f_inset] flex-col items-center justify-between">
|
||||||
<div className="relative p-3">
|
<div className="relative p-3">
|
||||||
<span className="text-[70px] tracking-tighter font-bold font-mono bg-gradient-to-b dark:from-stone-200 dark:via-stone-400 dark:to-stone-700 bg-clip-text text-transparent drop-shadow-[0_0_10px_rgba(255,255,255,0.1)] from-stone-800 via-stone-600 to-stone-400">
|
<span className="text-[70px] tracking-tighter font-bold font-mono bg-gradient-to-b dark:from-stone-200 dark:via-stone-400 dark:to-stone-700 bg-clip-text text-transparent drop-shadow-[0_0_10px_rgba(255,255,255,0.1)] from-stone-800 via-stone-600 to-stone-400">
|
||||||
{parseInt(kFormatter(npmDownloads) as string)}k+
|
{kFormatter(npmDownloads) as string}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex -p-8 items-end w-full gap-2 mt-4 text-gray-400">
|
<div className="flex -p-8 items-end w-full gap-2 mt-4 text-gray-400">
|
||||||
|
|||||||
@@ -9,9 +9,17 @@ export function absoluteUrl(path: string) {
|
|||||||
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`;
|
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`;
|
||||||
}
|
}
|
||||||
export function kFormatter(num: number) {
|
export function kFormatter(num: number) {
|
||||||
return Math.abs(num) > 999
|
const absNum = Math.abs(num);
|
||||||
? Math.sign(num) * parseFloat((Math.abs(num) / 1000).toFixed(1)) + "k"
|
const sign = Math.sign(num);
|
||||||
: Math.sign(num) * Math.abs(num);
|
|
||||||
|
if (absNum >= 1000000000) {
|
||||||
|
return sign * parseFloat((absNum / 1000000000).toFixed(1)) + "B+";
|
||||||
|
} else if (absNum >= 1000000) {
|
||||||
|
return sign * parseFloat((absNum / 1000000).toFixed(1)) + "M+";
|
||||||
|
} else if (absNum >= 1000) {
|
||||||
|
return sign * parseFloat((absNum / 1000).toFixed(1)) + "K+";
|
||||||
|
}
|
||||||
|
return sign * absNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const baseUrl =
|
export const baseUrl =
|
||||||
|
|||||||
Reference in New Issue
Block a user