import type { Metadata } from 'next'; import Link from 'next/link'; import { EXAMPLE_QUERIES, GroupedResults, Shortcuts } from '@/components/search/results'; import { SearchForm } from '@/components/search/search-form'; import { Container, PageHeader } from '@/components/ui/section'; import { Unavailable } from '@/components/ui/unavailable'; import { api, safe } from '@/lib/api'; import { fmtInt } from '@/lib/format'; import { routes, SITE_URL } from '@/lib/site'; export const dynamic = 'force-dynamic'; type SP = Promise>; function readQ(sp: Record): string { const raw = Array.isArray(sp.q) ? sp.q[0] : sp.q; return (raw ?? '').trim().slice(0, 120); } export async function generateMetadata({ searchParams }: { searchParams: SP }): Promise { const q = readQ(await searchParams); const title = q ? `Search results for “${q}”` : 'Search satellites, operators, constellations and launches'; return { title, description: q ? `SatelliteIndex search results for “${q}”: satellites, constellations, operators, countries, launches and launch sites.` : 'Search the SatelliteIndex catalogue by satellite name, NORAD or COSPAR identifier, operator, constellation, country or launch.', alternates: { canonical: q ? routes.search(q) : '/search' }, robots: q ? { index: false, follow: true } : { index: true, follow: true }, openGraph: { title, url: `${SITE_URL}${routes.search(q || undefined)}`, type: 'website' }, }; } export default async function SearchPage({ searchParams }: { searchParams: SP }) { const q = readQ(await searchParams); const res = q ? await safe(api.search(q, 50)) : null; const payload = res?.data ?? null; const failed = Boolean(q) && res === null; return ( Results for “{q}” : 'Search the index'} lede={q ? undefined : 'Satellites by name, NORAD or COSPAR identifier; constellations, operators, countries, launches and launch sites. Press ⌘K anywhere for the quick search.'} />
{!q ? (

Try

    {EXAMPLE_QUERIES.map((ex) => (
  • {ex}
  • ))}

Launch vehicles are not indexed yet — a query such as “Falcon 9” only matches objects whose catalogue name contains those words. Browse the{' '} launch log or filter the catalogue instead.

) : failed ? ( ) : payload ? ( <> {payload.results.length === 0 ? (

No results for “{q}”.

The index covers satellite names, NORAD and COSPAR identifiers, constellations, operators, countries, launches and launch sites. Launch vehicles (e.g. “Falcon 9”) are not indexed yet.

Filter the catalogue for “{q}” Open the live globe
) : ( <>

{fmtInt(payload.results.length)} result{payload.results.length === 1 ? '' : 's'} {payload.results.length >= 50 && ' (top 50 by relevance)'}

)} ) : null}
); }