import { Link, useSearchParams } from "react-router"; import type { SearchResult } from "../api"; import { useFetch } from "../hooks"; import { Badge, Empty, ErrorBox, Loading } from "../components/ui"; import { routeFor } from "../components/Graph"; export default function SearchPage() { const [sp] = useSearchParams(); const q = sp.get("q") ?? ""; const { data, error, loading } = useFetch<{ query: string; results: SearchResult[] }>(q ? `search?q=${encodeURIComponent(q)}&limit=50` : null); const groups = new Map(); for (const r of data?.results ?? []) groups.set(r.type, [...(groups.get(r.type) ?? []), r]); return (

Search

“{q}” — full-text and trigram search over APIs, endpoints, variables and packages.

{loading && } {data && data.results.length === 0 && No results. Register the API from API Atlas → Discover.} {Array.from(groups.entries()).map(([type, rs]) => (

{type} ({rs.length})

{rs.map((r) => (
{r.title} {r.provider}
{r.snippet?.slice(0, 140)}
))}
))}
); }