This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getActivePages = ({ activePage = 1, pageListLength, pages }) => { | |
const pageCount = pages < pageListLength ? pages : pageListLength; | |
const array = Array.from({ length: pageCount }); | |
const middle = Math.ceil(pageCount / 2); | |
// When the page number is less than the median of the displayed pages, show first n pages | |
if (activePage < middle) { | |
return array.map((_, index) => index + 1); | |
} |