Skip to content

Node.js based forum software built for the modern web

add itemsPerPage to search api

Baris Usakli2ee743d65ca1
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);