"use client"; import { useEffect, useState } from "react"; import { Download } from "reicon-react/icons/Download"; import { Container } from "../ui/container"; import { Reveal } from "../ui/reveal"; import { SectionHeading } from "../ui/section-heading"; import { platformDownloads, releaseVersion } from "../../lib/release-links.generated"; import { DOWNLOAD_COUNT_SEED, getTrackedDownloadHref } from "../../lib/downloads"; export function DownloadSection() { const [downloadCount, setDownloadCount] = useState(DOWNLOAD_COUNT_SEED); useEffect(() => { let cancelled = false; async function loadDownloadCount() { try { const response = await fetch("/api/download-stats", { cache: "no-store" }); if (!response.ok) { throw new Error(`Failed to fetch download count: ${response.status}`); } const data = (await response.json()) as { downloads?: number }; if (!cancelled && typeof data.downloads === "number") { setDownloadCount(data.downloads); } } catch { // Keep the seeded count visible when the dynamic endpoint is unavailable. } } void loadDownloadCount(); return () => { cancelled = true; }; }, []); return (

Version {releaseVersion} ยท {downloadCount.toLocaleString("en-US")} downloads

{platformDownloads.map((platform) => (

{platform.title}

{platform.note}

{platform.assets.map((asset) => ( {asset.label} ))}
))}
); }