refactor media page to support pagination
This commit is contained in:
parent
468ff48bfe
commit
012acdb869
7 changed files with 131 additions and 25 deletions
|
@ -1,11 +1,12 @@
|
|||
import Link from '@/components/Link'
|
||||
|
||||
interface Props {
|
||||
page: string
|
||||
totalPages: number
|
||||
currentPage: number
|
||||
}
|
||||
|
||||
export default function Pagination({ totalPages, currentPage }: Props) {
|
||||
export default function Pagination({ page, totalPages, currentPage }: Props) {
|
||||
const prevPage = currentPage - 1 > 0
|
||||
const nextPage = currentPage + 1 <= totalPages
|
||||
|
||||
|
@ -18,7 +19,7 @@ export default function Pagination({ totalPages, currentPage }: Props) {
|
|||
</button>
|
||||
)}
|
||||
{prevPage && (
|
||||
<Link href={currentPage - 1 === 1 ? `/blog/` : `/blog/page/${currentPage - 1}`}>
|
||||
<Link href={currentPage - 1 === 1 ? `/${page}/` : `/${page}/page/${currentPage - 1}`}>
|
||||
<button>Previous</button>
|
||||
</Link>
|
||||
)}
|
||||
|
@ -31,7 +32,7 @@ export default function Pagination({ totalPages, currentPage }: Props) {
|
|||
</button>
|
||||
)}
|
||||
{nextPage && (
|
||||
<Link href={`/blog/page/${currentPage + 1}`}>
|
||||
<Link href={`/${page}/page/${currentPage + 1}`}>
|
||||
<button>Next</button>
|
||||
</Link>
|
||||
)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue