<% if (pageCnt) { %>
<% let leftCnt = page - 1, rightCnt = pageCnt - page, omitLeft = leftCnt > 4, omitRight = rightCnt > 4; if (omitLeft) leftCnt = 3; if (omitRight) rightCnt = 3; if (omitLeft) { %>
  • ...
  • <% } for (let i = page - leftCnt; i < page; i++) { %> <%= i %> <% } %> <%= page %> <% for (let i = page + 1; i <= page + rightCnt; i++) { %> <%= i %> <% } if (omitRight) { %>
  • ...
  • <% } %>
    <% } %>