mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #486 from jgable/fixRedirectLoop
Fix redirect loop when no content
This commit is contained in:
commit
6c6119a5c8
1 changed files with 10 additions and 2 deletions
|
@ -21,9 +21,17 @@ frontendControllers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
api.posts.browse({page: pageParam}).then(function (page) {
|
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 page is greater than number of pages we have, redirect to last page
|
||||||
if (pageParam > page.pages) {
|
if (pageParam > maxPage) {
|
||||||
return res.redirect("/page/" + (page.pages) + "/");
|
return res.redirect("/page/" + maxPage + "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the page of posts
|
// Render the page of posts
|
||||||
|
|
Loading…
Add table
Reference in a new issue