From 0c3adbf9e54871bdae1eaf31afe60fdea8775b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=EB=8D=94?= Date: Tue, 26 Jan 2021 11:37:55 +0900 Subject: [PATCH] fix: paginator --- components/Paginator.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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]} ...