{% macro render(url, total_pages, current_page, max_pages=0, archive_url=None, query='') -%} {% if total_pages > 1 %}
{% for page in range(1 if current_page <= 6 else [1, current_page - 5] | max, ([total_pages, max_pages] | min if max_pages else [total_pages, current_page + 5] | min) + 1) %} {% if page == current_page %} {{ page }} {% else %} {{ page }} {% endif %} {% endfor %} {% if total_pages >= max_pages and archive_url %} {% endif %} {% if current_page < total_pages %} {% endif %}
{% endif %} {%- endmacro %}