Skip to content

Commit

Permalink
Make search result paging work
Browse files Browse the repository at this point in the history
  • Loading branch information
nolze committed Sep 16, 2020
1 parent c11048f commit 6ee6fed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions view/src/pages/Search.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
$: q = query.q;
$: order = query.ord || 'updated';
$: start = parseInt(query.start) || 0;
$: limit = parseInt(query.limit) || 10;
$: fetchResults = async () => {
return await api
.get(`/search`, { params: { q, start, ord: order } })
.get(`/search`, { params: { q, start, limit, ord: order } })
.then((resp) => resp.data)
.catch(() => {});
};
Expand Down Expand Up @@ -51,11 +52,11 @@
{/await}
<div class="text-sm mt-8 flex">
<Link
to="search?q={q}{'&'}ord={order}&start=0"
to="search?q={q}{'&'}ord={order}{'&'}start={start-limit < 0 ? 0 : start-limit}"
class={start === 0 ? 'text-gray-600' : ''}>
Previous
</Link><span class="mx-2" />
<Link to="search?q={q}{'&'}ord={order}&start=0">Next</Link>
<Link to="search?q={q}{'&'}ord={order}{'&'}start={start+limit}">Next</Link>
</div>
</main>
</div>
Expand Down

0 comments on commit 6ee6fed

Please sign in to comment.