import { ArrowUpRight } from "lucide-react" import type { Site } from "@/lib/types" import { catFrom, catTo } from "@/lib/category" import { DAY, full, isoDay, num, toTime } from "@/lib/format" import { href } from "@/lib/route" import { Spark } from "@/components/sparkline" import { catName, T } from "@/lib/i18n" /** One block per modality: how big its community is, which releases it holds, who builds on it. */ export function CategoryBlocks({ site }: { site: Site }) { return (
{site.categories.map((c, i) => )}
) } function Block({ site, cat, wide }: { site: Site; cat: string; wide: boolean }) { const c = site.categories.find((x) => x.key === cat)! const rels = c.releases.map((k) => site.releases.find((r) => r.key === k)!) const n = rels.reduce((a, r) => a + r.n, 0) const dl = rels.reduce((a, r) => a + r.dlall, 0) const off = rels.reduce((a, r) => a + (r.official.dlall ?? 0), 0) const events = rels.flatMap((r) => r.growth) // The curve starts a week before the first community model, so a modality whose community // is new still gets a readable curve rather than a flat line and a cliff. const firstEvent = events.reduce((a, [d]) => (d < a ? d : a), "9999") const first = firstEvent < "9999" ? isoDay(toTime(firstEvent) - 7 * DAY) : rels.reduce((a, r) => (r.date < a ? r.date : a), rels[0].date) const repoCount = rels.reduce((a, r) => a + r.models.length, 0) const stats: [string, string][] = [ [num(dl), T.communityDownloads], [full(c.builders), T.builders], [num(off), T.minimaxDownloads], [full(repoCount), T.openModels(repoCount)], ] return (

{catName(c)}

{full(n)}
{T.communityModels}
{stats.map(([v, l]) => (
{l}
{v}
{l}
))}
{rels.map((r) => ( {r.name} {r.n > 0 && {full(r.n)}} ))}
{c.top_authors.length > 0 && (
{c.top_authors.map((a) => ( {a.a ? : a.id.slice(0, 1).toUpperCase()} ))}
{c.builders > c.top_authors.length && ( {T.moreBuilders(full(c.builders - c.top_authors.length))} )}
)}
r.date)} ring="#fff" />
) }