mirror of
https://github.com/Damillora/Shioriko.git
synced 2024-12-24 00:43:44 +00:00
fix: correct pagination issues
This commit is contained in:
parent
5123bc8a24
commit
c978c6eb50
@ -20,14 +20,14 @@
|
||||
let queryParams;
|
||||
$: queryParams = queryString.parse(location.search);
|
||||
if(queryParams.page) {
|
||||
page = queryParams.page;
|
||||
page = parseInt(queryParams.page);
|
||||
}
|
||||
getData();
|
||||
})
|
||||
|
||||
const handlePage = (i) => {
|
||||
return () => {
|
||||
page = 1;
|
||||
page = i;
|
||||
getData();
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@
|
||||
<a class="pagination-next">Next page</a>
|
||||
{/if}
|
||||
<ul class="pagination-list">
|
||||
{#if page > 2}
|
||||
{#if page > 3}
|
||||
<li>
|
||||
<Link on:click="{handlePage(1)}" to="/posts?page={1}" class="pagination-link" aria-label="Goto page 1">1</Link>
|
||||
</li>
|
||||
@ -72,7 +72,7 @@
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
{#if (totalPages - page) > 2}
|
||||
{#if (totalPages - page) > 3}
|
||||
<li>
|
||||
<span class="pagination-ellipsis">…</span>
|
||||
</li>
|
||||
|
@ -15,21 +15,21 @@
|
||||
const data = await getPostsTag({page, tag: id});
|
||||
if(Array.isArray(data.posts)) {
|
||||
posts = data.posts;
|
||||
totalPages = data.totalPage;
|
||||
}
|
||||
}
|
||||
onMount(() => {
|
||||
let queryParams;
|
||||
queryParams = queryString.parse(location.search);
|
||||
if(queryParams.page) {
|
||||
page = queryParams.page;
|
||||
totalPages = data.totalPage;
|
||||
page = parseInt(queryParams.page);
|
||||
}
|
||||
getData();
|
||||
})
|
||||
|
||||
const handlePage = (i) => {
|
||||
return () => {
|
||||
page = 1;
|
||||
page = i;
|
||||
getData();
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@
|
||||
<a class="pagination-next">Next page</a>
|
||||
{/if}
|
||||
<ul class="pagination-list">
|
||||
{#if page > 2}
|
||||
{#if page > 3}
|
||||
<li>
|
||||
<Link on:click="{handlePage(1)}" to="/tag/{id}?page={1}" class="pagination-link" aria-label="Goto page 1">1</Link>
|
||||
</li>
|
||||
@ -77,7 +77,7 @@
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
{#if (totalPages - page) > 2}
|
||||
{#if (totalPages - page) > 3}
|
||||
<li>
|
||||
<span class="pagination-ellipsis">…</span>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user