Skip to content

Commit

Permalink
Merge pull request TryGhost#5015 from felixrieseberg/iss4967
Browse files Browse the repository at this point in the history
Ensure correct url for prev/next links
  • Loading branch information
novaugust committed Mar 9, 2015
2 parents 26508e6 + 4b1ece9 commit 1ca96a8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/server/helpers/ghost_head.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ghost_head = function (options) {
majorMinor = /^(\d+\.)?(\d+)/,
trimmedVersion = this.version,
trimmedUrlpattern = /.+(?=\/page\/\d*\/)/,
tagOrAuthorPattern = /\/(tag)|(author)\//,
trimmedUrl, next, prev, tags,
ops = [],
structuredData,
Expand Down Expand Up @@ -76,12 +77,16 @@ ghost_head = function (options) {
trimmedUrl = self.relativeUrl.match(trimmedUrlpattern);
if (self.pagination.prev) {
prev = (self.pagination.prev > 1 ? prev = '/page/' + self.pagination.prev + '/' : prev = '/');
prev = (trimmedUrl) ? '/' + trimmedUrl + prev : prev;
prev = (trimmedUrl) ? trimmedUrl + prev : prev;
head.push('<link rel="prev" href="' + config.urlFor({relativeUrl: prev, secure: self.secure}, true) + '" />');
}
if (self.pagination.next) {
next = '/page/' + self.pagination.next + '/';
next = (trimmedUrl) ? '/' + trimmedUrl + next : next;
if (trimmedUrl) {
next = trimmedUrl + next;
} else if (tagOrAuthorPattern.test(self.relativeUrl)) {
next = self.relativeUrl.slice(0, -1) + next;
}
head.push('<link rel="next" href="' + config.urlFor({relativeUrl: next, secure: self.secure}, true) + '" />');
}
}
Expand Down

0 comments on commit 1ca96a8

Please sign in to comment.