|
|
@ -1,3 +1,11 @@ |
|
|
|
/** |
|
|
|
* Determines if the requested page is out of bounds |
|
|
|
* |
|
|
|
* @param page current page |
|
|
|
* @param postsPerPage - number of posts rendered on each page |
|
|
|
* @param totalPosts - total posts in this category/total |
|
|
|
* @returns {boolean} if this is a valid page |
|
|
|
*/ |
|
|
|
const isValidPage = function(page, postsPerPage, totalPosts) |
|
|
|
{ |
|
|
|
return !(page === 0 || page -1 >= totalPosts/postsPerPage); |
|
|
@ -5,6 +13,17 @@ const isValidPage = function(page, postsPerPage, totalPosts) |
|
|
|
|
|
|
|
module.exports= |
|
|
|
{ |
|
|
|
/** |
|
|
|
* Renders two buttons on the bottom of the page to |
|
|
|
* go to the left or right |
|
|
|
* |
|
|
|
* Used by the home page and categories pages |
|
|
|
* @param baseURL -- base url of page being rendered |
|
|
|
* @param currentPage -- current page being rendered |
|
|
|
* @param postsPerPage -- number of posts on each page |
|
|
|
* @param totalPosts -- total amount of posts in the category |
|
|
|
* @returns {Promise} promise which renders the buttons |
|
|
|
*/ |
|
|
|
main: function(baseURL, currentPage, postsPerPage, totalPosts) |
|
|
|
{ |
|
|
|
return new Promise(function(resolve, reject) |
|
|
|