From 8df18218cadd3065750ddb0c85d8302d42fb2ab8 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 17 Apr 2026 15:49:24 +0200 Subject: [PATCH] feat(search): auto-redirect to web search when no local hits Spares the user a click: empty local result set triggers goto('/search/web?q=...') with replaceState so the back button returns to the previous page, not the empty local results list. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/routes/search/+page.svelte | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index 3db71f0..2e414a0 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -17,6 +17,11 @@ const body = await res.json(); hits = body.hits; loading = false; + if (hits.length === 0) { + // Kein lokaler Treffer → automatisch im Internet weitersuchen. + // replaceState, damit die Zurück-Taste nicht zwischen leerer Liste und Web-Suche pingt. + void goto(`/search/web?q=${encodeURIComponent(q)}`, { replaceState: true }); + } } $effect(() => { @@ -47,10 +52,7 @@

Suche läuft …

{:else if searched && hits.length === 0}
-

Kein Rezept im Bestand für „{query}".

- - 🌐 Im Internet suchen - +

Kein lokales Rezept für „{query}" — suche jetzt im Internet …

{:else if hits.length > 0}