Compare commits

..

1 Commits

Author SHA1 Message Date
Adam Veldhousen e945fc2f79
pagination and linking improvements 2023-05-26 01:47:50 -05:00
1 changed files with 4 additions and 4 deletions

View File

@ -13,11 +13,9 @@
return qs !== '' ? `?${qs}` : qs;
}
const { query, page } = data;
$: hasResults = (data.results || []).length > 0;
$: currentPage = data.page + 1;
$: pageCount = Math.max(1, Math.ceil(data.found / data.limit));
$: console.log(`page: ${currentPage}, count: ${pageCount}, `);
</script>
{#if hasResults}
@ -26,7 +24,9 @@
<ol class="flex justify-between w-full center" style="padding: 0 10%;">
{#if currentPage > 1}
<li in:fade>
<a href="/{buildQueryString({ query, page: currentPage - 1 })}">&lt;Previous</a>
<a href="/{buildQueryString({ query: data.query, page: currentPage - 1 })}"
>&lt;Previous</a
>
</li>
{:else}
<li />
@ -34,7 +34,7 @@
<li>Page {currentPage} of {pageCount}</li>
{#if currentPage < pageCount}
<li in:fade>
<a href="/{buildQueryString({ query, page: currentPage + 1 })}">Next&gt;</a>
<a href="/{buildQueryString({ query: data.query, page: currentPage + 1 })}">Next&gt;</a>
</li>
{/if}
</ol>