From da0256ba5825e63697aef809178e5bb6025cb284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Fri, 12 Jan 2024 20:49:21 +0100 Subject: [PATCH] fix: snapshot query string, returning to pages will restore the query now (#99) --- src/routes/+page.svelte | 6 ++++++ src/routes/search/+page.svelte | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8a15e554..f91654d7 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,6 +2,12 @@ import logo from '$lib/assets/logo.svg'; import Searchbox from '$lib/components/Searchbox.svelte'; let query = ''; + + import type { Snapshot } from './$types'; + export const snapshot: Snapshot = { + capture: () => query, + restore: (value) => (query = value) + }; Hearchco diff --git a/src/routes/search/+page.svelte b/src/routes/search/+page.svelte index f4420e1b..ded2326a 100644 --- a/src/routes/search/+page.svelte +++ b/src/routes/search/+page.svelte @@ -6,16 +6,24 @@ import type { PageData } from './$types'; export let data: PageData; + let query = data.query; + + import type { Snapshot } from './$types'; + export const snapshot: Snapshot = { + capture: () => query, + restore: (value) => (query = value) + }; Search | Hearchco -
+
{#await data.streamed.results} {:then results} +
{#each results as result (result.URL)}