Searching works better now... :D
This commit is contained in:
parent
9ca85455af
commit
a71172aec3
|
@ -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 })
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -31,18 +31,26 @@
|
|||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro pager(pageNum, maxPage) %}
|
||||
<a class="page {{ "current-page" if page === pageNum }}" href="?page=1">1</a>
|
||||
{% macro pageLink(pageNum, currentPage, queries) %}
|
||||
{#
|
||||
Yes! :D
|
||||
I feel like I have brain damage...
|
||||
#}
|
||||
<a class="page {{ "current-page" if currentPage === pageNum }}" href="?{% for query, value in queries %}{{ query if query !== "page" }}{{ "=" if query !== "page" }}{{ value if query !== "page" }}{{ "&" if query !== "page" }}{% endfor %}page={{ pageNum }}">{{ pageNum }}</a>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro pager(pageNum, maxPage, queries) %}
|
||||
{{ pageLink(1, pageNum, queries) }}
|
||||
<p>{{ "..." if (pageNum - 2 > 1) }}</p>
|
||||
|
||||
{% for page in range(pageNum - 2, pageNum + 3) %}
|
||||
{% if page > 1 and page < maxPage %}
|
||||
<a class="page {{ "current-page" if page === pageNum }}" href="?page={{ page }}">{{ page }}</a>
|
||||
{{ pageLink(page, pageNum, queries) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<p>{{ "..." if (pageNum + 2 < maxPage) }}</p>
|
||||
{% if maxPage > 1 %}
|
||||
<a class="page {{ "current-page" if page === pageNum }}" href="?page={{ maxPage }}">{{ maxPage }}</a>
|
||||
{{ pageLink(maxPage, pageNum, queries) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
|
@ -11,17 +11,17 @@
|
|||
<main class="flex-container">
|
||||
<form action="/maps" method="get" id="search">
|
||||
<h1>Search</h1>
|
||||
<input type="text" name="map" id="map" placeholder="Map name">
|
||||
<input type="text" name="categories" id="categories" placeholder="Category">
|
||||
<input type="text" name="stars" id="stars" placeholder="Star amount">
|
||||
<input type="text" name="map" id="map" placeholder="Map name" value="{{ options.query.map }}">
|
||||
<input type="text" name="categories" id="categories" placeholder="Category" value="{{ options.query.categories }}">
|
||||
<input type="text" name="stars" id="stars" placeholder="Star amount" value="{{ options.query.stars }}">
|
||||
|
||||
<div class="sorting">
|
||||
<label for="asc">
|
||||
<input type="radio" name="order" id="asc" value="asc">
|
||||
<input type="radio" name="order" id="asc" value="asc" {{ "checked" if options.query.sortyBy == "asc" }}>
|
||||
Sort Ascending
|
||||
</label>
|
||||
<label for="desc">
|
||||
<input type="radio" name="order" id="desc" value="desc">
|
||||
<input type="radio" name="order" id="desc" value="desc" {{ "checked" if options.query.sortyBy == "desc" }}>
|
||||
Sort Descending
|
||||
</label>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
</form>
|
||||
|
||||
<div class="flex-container pages">
|
||||
{{ utils.pager(data.maps.pageInfo.page, data.maps.pageInfo.totalPages) }}
|
||||
{{ utils.pager(data.maps.pageInfo.page, data.maps.pageInfo.totalPages, options.query) }}
|
||||
</div>
|
||||
|
||||
{% for map in data.maps.maps %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user