<%- include("./isDefaultCSS/pagination.ejs") %>
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
    <a class="pagination-previous" <% if (Number(req.query.page) <= 1) { %>disabled<% } else { %>href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= Number(req.query.page) - 1 %>"<% } %>><%= __("common.pagination.previous") %></a>
    <a class="pagination-next" <% if (Number(req.query.page) >= pages) { %>disabled<% } else { %>href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= Number(req.query.page) + 1 %>"<% } %>><%= __("common.pagination.next") %></a>
    <ul class="pagination-list">
        <% if (Number(req.query.page) <= 3) { %>
            <li>
                <% if (Number(req.query.page) === 1) { %>
                    <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "1") %>" aria-current="page">1</a>
                <% } else { %>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %>1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
                <% } %>
            </li>
            <% if (2 <= pages) { %>
                <% if (Number(req.query.page) === 2) { %>
                    <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "2") %>" aria-current="page">2</a>
                <% } else { %>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %>2" aria-label="<%= __("common.pagination.gotoPage", "2") %>">2</a>
                <% } %>
            <% } %>
            <% if (3 <= pages) { %>
                <li>
                    <% if (Number(req.query.page) === 3) { %>
                        <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", "3") %>" aria-current="page">3</a>
                    <% } else { %>
                        <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %>3" aria-label="<%= __("common.pagination.gotoPage", "3") %>">3</a>
                    <% } %>
                </li>
            <% } %>
            <% if (pages > 3) { %>
                <li>
                    <span class="pagination-ellipsis">&hellip;</span>
                </li>
                <li>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                </li>
            <% } %>
        <% } else { %>
            <li>
                <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %>1" aria-label="<%= __("common.pagination.gotoPage", "1") %>">1</a>
            </li>
            <li>
                <span class="pagination-ellipsis">&hellip;</span>
            </li>
            <% if (Number(req.query.page) === pages) { %>
                <li>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= Number(req.query.page) - 2 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 2) %>"><%= Number(req.query.page) - 2 %></a>
                </li>
            <% } %>
            <li>
                <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= Number(req.query.page) - 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) - 1) %>"><%= Number(req.query.page) - 1 %></a>
            </li>
            <li>
                <a class="pagination-link is-current" aria-label="<%= __("common.pagination.page", req.query.page) %>" aria-current="page"><%= req.query.page %></a>
            </li>
            <% if (Number(req.query.page) !== pages) { %>
                <li>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= Number(req.query.page) + 1 %>" aria-label="<%= __("common.pagination.gotoPage", Number(req.query.page) + 1) %>"><%= Number(req.query.page) + 1 %></a>
                </li>
            <% } %>
            <% if (Number(req.query.page <= (pages - 2))) { %>
                <li>
                    <span class="pagination-ellipsis">&hellip;</span>
                </li>
                <li>
                    <a class="pagination-link" href="<%= linkPrefix %>/<%= linkLocation %><%= pageParam %><%= pages %>" aria-label="<%= __("common.pagination.gotoPage", pages) %>"><%= pages %></a>
                </li>
            <% } %>
        <% } %>
    </ul>
</nav>