diff --git a/components/Paginator.tsx b/components/Paginator.tsx index f8c2b3f..e57ccc6 100644 --- a/components/Paginator.tsx +++ b/components/Paginator.tsx @@ -1,6 +1,6 @@ import Link from 'next/link' const Paginator = ({ currentPage, totalPage }:PaginatorProps):JSX.Element => { - const pages = [1, currentPage === 1 ? 2 : currentPage - 1, currentPage === 1 ? 3 : totalPage === currentPage ? currentPage - 2 : currentPage, currentPage + 1, totalPage ] + const pages = [1, currentPage >= totalPage - 1 ? totalPage - 2 : currentPage - 1, currentPage <= 2 ? 2 : currentPage >= totalPage - 1 ? totalPage - 1 : currentPage, currentPage <= 2 ? 3 : currentPage + 1, totalPage ] return
@@ -11,14 +11,14 @@ const Paginator = ({ currentPage, totalPage }:PaginatorProps):JSX.Element => {
{pages[0]} { - pages[1] - pages[0] <= 1 ? '' : <> + pages[1] - pages[0] <= 1 ? pages[2] - pages[0] <= 1 ? '' : ... : <> ... {pages[1]} } {pages[2] === pages[4] ? pages[4] - 1 : pages[2]} { - pages[4] - pages[3] <= 1 ? '' : <> + pages[4] - pages[3] <= 1 ? pages[4] - pages[2] <= 1 ? '' : ... : <> {pages[3]} ...