diff --git a/routes/routes.js b/routes/routes.js index 55cd7e7..5e89005 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -24,7 +24,7 @@ routes.get( const maps = wrapper.searchMap(map, categories.split(","), stars.split(","), sort, order, page) - tx(req, res)('pages/maps.njk', { maps }, true, { currentSection: "maps" }) + tx(req, res)('pages/maps.njk', { maps }, true, { currentSection: "maps", query: req.query }) } ) diff --git a/views/components/_utils.njk b/views/components/_utils.njk index 9b38d25..3b9493e 100644 --- a/views/components/_utils.njk +++ b/views/components/_utils.njk @@ -31,18 +31,26 @@ {%- endif -%} {% endmacro %} -{% macro pager(pageNum, maxPage) %} - 1 +{% macro pageLink(pageNum, currentPage, queries) %} + {# + Yes! :D + I feel like I have brain damage... + #} + {{ pageNum }} +{% endmacro %} + +{% macro pager(pageNum, maxPage, queries) %} + {{ pageLink(1, pageNum, queries) }}

{{ "..." if (pageNum - 2 > 1) }}

{% for page in range(pageNum - 2, pageNum + 3) %} {% if page > 1 and page < maxPage %} - {{ page }} + {{ pageLink(page, pageNum, queries) }} {% endif %} {% endfor %}

{{ "..." if (pageNum + 2 < maxPage) }}

{% if maxPage > 1 %} - {{ maxPage }} + {{ pageLink(maxPage, pageNum, queries) }} {% endif %} {% endmacro %} \ No newline at end of file diff --git a/views/pages/maps.njk b/views/pages/maps.njk index 66dd6f0..ca49146 100644 --- a/views/pages/maps.njk +++ b/views/pages/maps.njk @@ -11,17 +11,17 @@
- {{ utils.pager(data.maps.pageInfo.page, data.maps.pageInfo.totalPages) }} + {{ utils.pager(data.maps.pageInfo.page, data.maps.pageInfo.totalPages, options.query) }}
{% for map in data.maps.maps %}