0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Fix redirect loop when no content

This commit is contained in:
Jacob Gable 2013-08-21 09:05:17 -05:00
parent 1e95ec0c3d
commit 23ee4cadc3

View file

@ -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