From 2ee743d65ca121eb7d5aa3c3fb7f77dc9e16ffc1 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 9 Nov 2018 16:47:26 -0500 Subject: [PATCH] add itemsPerPage to search api --- src/controllers/search.js | 1 + src/search.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/search.js b/src/controllers/search.js index 833092ee70..62b453e266 100644 --- a/src/controllers/search.js +++ b/src/controllers/search.js @@ -50,6 +50,7 @@ searchController.search = function (req, res, next) { sortBy: req.query.sortBy || meta.config.searchDefaultSortBy || '', sortDirection: req.query.sortDirection, page: page, + itemsPerPage: req.query.itemsPerPage, uid: req.uid, qs: req.query, }; diff --git a/src/search.js b/src/search.js index 7d8a6f3e09..2beeb85863 100644 --- a/src/search.js +++ b/src/search.js @@ -116,7 +116,7 @@ function searchInContent(data, callback) { next(null, Object.assign({ posts: posts, matchCount: matchCount, - pageCount: Math.max(1, Math.ceil(parseInt(matchCount, 10) / 10)), + pageCount: Math.max(1, Math.ceil(parseInt(matchCount, 10) / itemsPerPage)), }, metadata)); }, ], callback);