Skip to content

Commit 9a6061b

Browse files
committed
feat: implemented pagination on [alpha]/[page] pagination route
1 parent ff5768d commit 9a6061b

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/pages/browse/[alpha]/[page].astro

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ export async function getStaticPaths({ paginate }) {
2929
<BaseLayout
3030
pageTitle={`Browse jargons.dev`}
3131
subtitle={`Words Starting With "${params.alpha.toUpperCase()}" (Page ${page.currentPage})`}
32+
class="min-h-screen flex flex-col"
3233
>
3334
<Navbar>
3435
<Search triggerSize="sm" dictionary={dictionary} client:load />
3536
</Navbar>
3637

37-
<main class="max-w-screen-lg p-5 md:mt-10 mx-auto min-h-screen space-y-6">
38+
<main class="w-full max-w-screen-lg grow flex flex-col p-5 md:mt-10 mx-auto space-y-6">
39+
<!-- Page Title -->
3840
<h1 class="text-3xl md:text-5xl font-black">
3941
Browse: Letter { params.alpha.toUpperCase() }
4042
</h1>
43+
44+
<!-- Words List -->
4145
<div>
4246
{page.data.map(word => (
4347
<a href={`/browse/${word.slug}`}
@@ -50,5 +54,26 @@ export async function getStaticPaths({ paginate }) {
5054
</a>
5155
))}
5256
</div>
57+
58+
<!-- Pagination -->
59+
<div class="w-full flex !mt-auto">
60+
<div class="mx-auto flex items-center space-x-4">
61+
{page.url.prev ? (
62+
<a href={page.url.prev} class="bg-black text-white no-underline rounded py-1 px-2">Previous</a>
63+
) : (
64+
<span class="bg-gray-100 text-gray-400 cursor-not-allowed no-underline rounded py-1 px-2">Previous</span>
65+
)}
66+
67+
<span>
68+
Page { page.currentPage }
69+
</span>
70+
71+
{page.url.next ? (
72+
<a href={page.url.next} class="bg-black text-white no-underline rounded py-1 px-2">Next</a>
73+
) : (
74+
<span class="bg-gray-100 text-gray-400 cursor-not-allowed no-underline rounded py-1 px-2">Next</span>
75+
)}
76+
</div>
77+
</div>
5378
</main>
5479
</BaseLayout>

0 commit comments

Comments
 (0)