-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathPagination.astro
55 lines (50 loc) · 1.45 KB
/
Pagination.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
import Link from "./Link.astro";
import { getCollection } from "astro:content";
import { startPagePath } from "../lib/utils";
type Props = {
order: number;
};
const { order } = Astro.props;
const startPages = await getCollection("start");
const previousPage = startPages.find(
({ data: { order: pageOrder } }) => pageOrder === order - 1,
);
const nextPage = startPages.find(
({ data: { order: pageOrder } }) => pageOrder === order + 1,
);
---
<div
class="flex flex-col-reverse gap-3 tracking-tight md:flex-row md:items-center md:justify-between md:gap-0 md:space-y-0 md:text-lg lg:text-xl"
>
{/* Previous page */}
<div>
{
previousPage && (
<Link
href={startPagePath(previousPage.slug)}
class="flex space-x-3 rounded-lg font-semibold"
>
<span class="text-gray">←</span>
<span class="tracking-tight hover:text-gray dark:hover:text-light-gray">
{previousPage.data.title}
</span>
</Link>
)
}
</div>
{/* Next page */}
<div>
{
nextPage && (
<Link
href={startPagePath(nextPage.slug)}
class="flex justify-between space-x-3 rounded-full border-1.5 border-primary px-4 py-2 font-semibold hover:bg-pale dark:hover:bg-darker-gray md:px-5 md:py-3"
>
<span class="tracking-tight">{nextPage.data.title}</span>
<span class="text-primary">→</span>
</Link>
)
}
</div>
</div>