SPB Git forge

spb/websensor

Public
33commits 1branches 0releases
3.4 MBsize
maindefault branch
10 days agolast push
TypeScript 55.4% Python 43.2% SQL 1.2%
1.9 KB · 40 lines tsx
Raw Blame History
1import type { Metadata } from "next";2import Link from "next/link";3import { LiveFeed } from "@/components/live-feed";4import { filtersFromParams } from "@/lib/feed-filters";5import { PageHeader } from "@/components/ui";6import { api, type EventQuery } from "@/lib/api";7import { SAVED_VIEWS, feedHref } from "@/lib/format";89export const dynamic = "force-dynamic";10export const metadata: Metadata = { title: "Live", description: "Every meaningful change detected on the public web, live. Filters persist in the URL and can be shared." };1112/** Full-width live feed with URL-persisted filters (spec §99) and saved views (spec §100). */13export default async function LivePage({ searchParams }: { searchParams: Promise<Record<string, string | undefined>> }) {14  const sp = await searchParams;15  const f = filtersFromParams(sp);16  const q: EventQuery = { ...f, limit: 60 };17  const events = await api.events(q);18  const activeView = SAVED_VIEWS.find((v) => Object.entries(v.query).every(([k, val]) => String(sp[k] ?? "") === String(val)) && Object.keys(sp).length === Object.keys(v.query).length);19  return (20    <>21      <PageHeader22        compact23        kicker="Live feed"24        title={activeView ? activeView.label : "Live"}25        description="Everything WebSensor detects, as it happens. Filters live in the URL — share the link to share the view."26        actions={27          <div className="flex flex-wrap gap-1">28            {SAVED_VIEWS.map((v) => (29              <Link key={v.key} href={feedHref(v.query, "/live")} className={`rounded-md border px-2 py-1 text-[11.5px] ${activeView?.key === v.key ? "border-signal/50 bg-signal-soft text-signal" : "border-line text-fg-muted hover:text-fg"}`}>30                {v.label}31              </Link>32            ))}33          </div>34        }35      />36      <LiveFeed key={JSON.stringify(f)} initial={events.items} initialCursor={events.nextCursor} initialFilters={f} syncUrl showTabs={!f.category} title="LIVE WEB" />37    </>38  );39}40