2014-10-10 18:54:07 +04:00
|
|
|
// ### Page URL Helper
|
|
|
|
//
|
|
|
|
// *Usage example:*
|
|
|
|
// `{{page_url 2}}`
|
|
|
|
//
|
|
|
|
// Returns the URL for the page specified in the current object
|
|
|
|
// context.
|
|
|
|
//
|
|
|
|
// We use the name page_url to match the helper for consistency:
|
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
|
|
|
|
var config = require('../config'),
|
|
|
|
errors = require('../errors'),
|
2015-11-12 15:29:45 +03:00
|
|
|
i18n = require('../i18n'),
|
2014-10-10 18:54:07 +04:00
|
|
|
page_url,
|
|
|
|
pageUrl;
|
|
|
|
|
2016-02-21 21:48:44 +03:00
|
|
|
page_url = function (pageNum, options) {
|
2014-10-10 18:54:07 +04:00
|
|
|
/*jshint unused:false*/
|
|
|
|
var url = config.paths.subdir;
|
|
|
|
|
|
|
|
if (this.tagSlug !== undefined) {
|
2015-01-31 01:20:47 +03:00
|
|
|
url += '/' + config.routeKeywords.tag + '/' + this.tagSlug;
|
2014-10-10 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.authorSlug !== undefined) {
|
2015-01-31 01:20:47 +03:00
|
|
|
url += '/' + config.routeKeywords.author + '/' + this.authorSlug;
|
2014-10-10 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
2016-02-21 21:48:44 +03:00
|
|
|
if (pageNum > 1) {
|
|
|
|
url += '/' + config.routeKeywords.page + '/' + pageNum;
|
2014-10-10 18:54:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
url += '/';
|
|
|
|
|
|
|
|
return url;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ### Page URL Helper: DEPRECATED
|
|
|
|
//
|
|
|
|
// *Usage example:*
|
|
|
|
// `{{pageUrl 2}}`
|
|
|
|
//
|
|
|
|
// Returns the URL for the page specified in the current object
|
|
|
|
// context. This helper is deprecated and will be removed in future versions.
|
|
|
|
//
|
2016-02-21 21:48:44 +03:00
|
|
|
pageUrl = function (pageNum, options) {
|
2015-11-12 15:29:45 +03:00
|
|
|
errors.logWarn(i18n.t('warnings.helpers.page_url.isDeprecated'));
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
/*jshint unused:false*/
|
|
|
|
var self = this;
|
|
|
|
|
2016-02-21 21:48:44 +03:00
|
|
|
return page_url.call(self, pageNum, options);
|
2014-10-10 18:54:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = page_url;
|
|
|
|
module.exports.deprecated = pageUrl;
|