diff --git a/frontend/src/components/VideoCard.jsx b/frontend/src/components/VideoCard.jsx index f03e8b5..4e3f268 100644 --- a/frontend/src/components/VideoCard.jsx +++ b/frontend/src/components/VideoCard.jsx @@ -19,6 +19,14 @@ function formatDate(dateStr) { return d.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }); } +function formatViews(n) { + if (!n) return null; + if (n >= 1_000_000_000) return `${(n / 1_000_000_000).toFixed(1)}B views`; + if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n >= 100_000_000 ? 0 : 1)}M views`; + if (n >= 1_000) return `${Math.round(n / 1_000)}K views`; + return `${n} views`; +} + function IconBtn({ onClick, title, active, pending, children }) { return (