Skip to content

Commit

Permalink
fix: snapshot query string, returning to pages will restore the query…
Browse files Browse the repository at this point in the history
… now (#99)
  • Loading branch information
aleksasiriski authored Jan 12, 2024
1 parent 33beb04 commit da0256b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
</script>

<svelte:head><title>Hearchco</title></svelte:head>
Expand Down
10 changes: 9 additions & 1 deletion src/routes/search/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
</script>

<svelte:head><title>Search | Hearchco</title></svelte:head>

<Header query={data.query} />
<Header bind:query />

{#await data.streamed.results}
<!-- todo: will change animation if not up to standard -->
<Load />
{:then results}
<!-- todo: await deep results and offer button to switch to them -->
<div class="sm:mx-auto mb-4 max-w-screen-sm">
<div id="result-list" class="mx-2 my-4 max-w-fit overflow-clip">
{#each results as result (result.URL)}
Expand Down

0 comments on commit da0256b

Please sign in to comment.