import { Suspense } from "react"; import { GitHubIcon } from "@/components/github-icon"; const REPO = "kaelio/ktx"; const REPO_URL = `https://github.com/${REPO}`; const API_URL = `https://api.github.com/repos/${REPO}`; async function fetchStarCount(): Promise { try { const res = await fetch(API_URL, { headers: { Accept: "application/vnd.github+json" }, // Revalidate hourly. GitHub's unauthenticated REST limit is 60 req/h per // IP, so a single cached server-side fetch keeps the count fresh while // never exposing visitors to rate limits or layout shift. next: { revalidate: 3600 }, }); if (!res.ok) return null; const data = (await res.json()) as { stargazers_count?: unknown }; return typeof data.stargazers_count === "number" ? data.stargazers_count : null; } catch { return null; } } /** Compact, GitHub-style count: 847 → "847", 1234 → "1.2k", 12345 → "12.3k". */ function formatStars(count: number): string { if (count < 1000) return count.toLocaleString("en-US"); const thousands = count / 1000; const rounded = thousands >= 100 ? Math.round(thousands) : Math.round(thousands * 10) / 10; return `${rounded}k`; } function StarGlyph() { return ( ); } async function StarsContent() { const count = await fetchStarCount(); const label = count === null ? "Star ktx on GitHub" : `Star ktx on GitHub — ${count.toLocaleString("en-US")} stars`; return ( Star {count !== null && ( {formatStars(count)} )} ); } function StarsSkeleton() { return (