From 54be576a8cc13df697254240e6ede98efaaf71ff Mon Sep 17 00:00:00 2001 From: Perception Date: Mon, 21 Dec 2020 22:30:14 -0800 Subject: [PATCH] Generalize pagination to work with things other than search --- routes/search.js | 3 ++- templates/_pagination.ejs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/search.js b/routes/search.js index 2774ba9..dc47d62 100644 --- a/routes/search.js +++ b/routes/search.js @@ -20,11 +20,12 @@ module.exports.GET = async (req, res) => { } // Search, if we have a query. + const path = `/search?q=${url.search.q}&` const {limit, offset} = pagination.getValuesToPaginate({ currentPage: p, perPage: PER_PAGE }) const results = await ds.search(db, q, limit, offset) const count = await ds.searchCount(db, q) const totalPages = pagination.getTotalPages({ totalItems: count, perPage: PER_PAGE }) - const out = await page.render('search', { q, rawQ: url.search.q, p, results, count, totalPages }) + const out = await page.render('search', { path, q, p, results, count, totalPages }) return send(res, 200, out) //return send(res, 200, { results, count }) diff --git a/templates/_pagination.ejs b/templates/_pagination.ejs index dcc5fcc..6b8cefc 100644 --- a/templates/_pagination.ejs +++ b/templates/_pagination.ejs @@ -8,7 +8,7 @@ <% if (i == p) { %> <%- i %>  <% } else { %> - <%- i %>  + <%- i %>  <% } %> <% } %>