import Link from "next/link"; import { listDocuments } from "@/lib/wiki"; import { ChatBubble } from "@/components/chat-bubble"; import { BatchProgressBanner } from "@/components/batch-progress-banner"; import { getLocale } from "@/components/locale-toggle"; import { SiteHeader } from "@/components/site-header"; import { HeroBanner } from "@/components/hero-banner"; import { FeaturedCase } from "@/components/featured-case"; import { IconicCases } from "@/components/iconic-cases"; import { PortalGrid, type PortalCounts } from "@/components/portal-grid"; import { GreatestHits } from "@/components/greatest-hits"; import { pgQuery } from "@/lib/retrieval/db"; // Read wiki/ filesystem + DB at request time, not build time. export const dynamic = "force-dynamic"; async function loadCounts(documentsCount: number): Promise { const rows = await pgQuery<{ entity_class: string; c: string }>( `SELECT entity_class, COUNT(*)::text AS c FROM public.entities GROUP BY entity_class`, ).catch(() => [] as Array<{ entity_class: string; c: string }>); const by: Record = {}; for (const r of rows) by[r.entity_class] = Number(r.c); return { events: by.event ?? 0, people: by.person ?? 0, uap_objects: by.uap_object ?? 0, locations: by.location ?? 0, operations: by.organization ?? 0, documents: documentsCount, }; } export default async function Home() { const ids = await listDocuments(); const locale = (await getLocale()) === "en" ? "en" : "pt-br"; const counts = await loadCounts(ids.length); return (
{/* "The primary record" — compact CTA into /documents instead of re-rendering the full filterable list on the homepage. The previous in-home bento of 122 cards stretched mobile to ~68k px tall on its own. */}
{locale === "en" ? "// The primary record" : "// O registro primário"}

{locale === "en" ? "Every document, indexed and searchable" : "Cada documento, indexado e buscável"}

{locale === "en" ? `${ids.length} declassified files — memos, telegrams, intelligence reports.` : `${ids.length} arquivos desclassificados — memorandos, telegramas, relatórios de inteligência.`}

{locale === "en" ? "Browse documents →" : "Ver documentos →"}
{/* JSON-LD: WebSite + ItemList of recent docs (helps GEO discovery) */}