import Link from "next/link"; import { readMeta, listGroups } from "@/lib/store"; import type { FileRecord } from "@/lib/store"; import BrowseClient from "./BrowseClient"; function formatBytes(n: number) { if (n < 1024) return `${n} B`; if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`; return `${(n / 1024 / 1024).toFixed(2)} MB`; } function TypeBadge({ type }: { type: FileRecord["type"] }) { return type === "backerup" ? ( .backerup ) : ( .json config ); } export default async function BrowsePage({ searchParams, }: { searchParams: Promise<{ group?: string }>; }) { const { group: selectedGroup } = await searchParams; const [allRecords, groups] = await Promise.all([readMeta(), listGroups()]); const records = selectedGroup ? allRecords.filter((r) => r.group === selectedGroup) : allRecords; return (
{records.length} file{records.length !== 1 ? "s" : ""} {selectedGroup ? ` in "${selectedGroup}"` : " shared by the community"}.
ðŸ“
{selectedGroup ? `No files in group "${selectedGroup}".` : "No files shared yet."}
Be the first to share one →{r.displayName ?? r.containerName}
)} {r.image && ({r.image}
)} {r.description && ({r.description}
)}