diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index 7fb95e47d4..97f62cc931 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -21,9 +21,17 @@ frontendControllers = { } api.posts.browse({page: pageParam}).then(function (page) { + var maxPage = page.pages; + + // A bit of a hack for situations with no content. + if (maxPage === 0) { + maxPage = 1; + page.pages = 1; + } + // If page is greater than number of pages we have, redirect to last page - if (pageParam > page.pages) { - return res.redirect("/page/" + (page.pages) + "/"); + if (pageParam > maxPage) { + return res.redirect("/page/" + maxPage + "/"); } // Render the page of posts