Search and sort
The shop and collection pages have a search box and a sort control, backed by
searchProducts and sortProducts in shared/catalog.ts. Matching is case- and
diacritic-insensitive across name, description and bullet points, and every typed
term has to match: “blue tote” returns blue totes, not everything blue.
It filters client-side
Section titled “It filters client-side”Against the catalogue the storefront already loaded from /api/store. That is
instant, costs no request, and works against the bundled fixture with
VITE_BELUGA_API=false.
?q= and ?sort= live in the URL, so a result is shareable, survives a reload, and
the back button undoes a search rather than one keystroke.
When the catalogue outgrows the snapshot
Section titled “When the catalogue outgrows the snapshot”/api/store is capped at STORE_SNAPSHOT_LIMIT, 200 live products. Past that, the
swap is to GET /api/products?search=&collection=&limit=&offset=, which already
exists and applies the same matching on the server, behind
src/lib/store-source.ts, the same seam that absorbed the fixture-to-database
change. No component needs to know.