forked from craigary/nobelium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPagination.js
44 lines (42 loc) · 1.17 KB
/
Pagination.js
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
import Link from 'next/link'
import BLOG from '@/blog.config'
import { useLocale } from '@/lib/locale'
const Pagination = ({ page, showNext }) => {
const locale = useLocale()
const currentPage = +page
let additionalClassName = 'justify-between'
if (currentPage === 1 && showNext) additionalClassName = 'justify-end'
if (currentPage !== 1 && !showNext) additionalClassName = 'justify-start'
return (
<div className={`flex font-medium text-black dark:text-gray-100 ${additionalClassName}`}>
{currentPage !== 1 && (
<Link
href={
currentPage - 1 === 1
? `${BLOG.path || '/'}`
: `/page/${currentPage - 1}`
}
>
<a>
<button
rel="prev"
className="block cursor-pointer"
>
← {locale.PAGINATION.PREV}
</button>
</a>
</Link>
)}
{showNext && (
<Link href={`/page/${currentPage + 1}`}>
<a>
<button rel="next" className="block cursor-pointer">
{locale.PAGINATION.NEXT} →
</button>
</a>
</Link>
)}
</div>
)
}
export default Pagination