mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 09:52:09 +03:00
10fc320cc8
no issue - In Ghost, 'context' means the page or section of a blog we're currently within when rendering a theme, e.g. 'post' or 'tag' or 'home'. - In handlebars 'context' refers to the blob of JSON that is tied to a template. - These two uses of the word 'context' have gotten very confusing, so I've removed all usage of 'context' within the Ghost handlebars helpers, EXCEPT where they actually refer to the current context (e.g. the is helper)
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
// ### 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'),
|
|
i18n = require('../i18n'),
|
|
page_url,
|
|
pageUrl;
|
|
|
|
page_url = function (pageNum, options) {
|
|
/*jshint unused:false*/
|
|
var url = config.paths.subdir;
|
|
|
|
if (this.tagSlug !== undefined) {
|
|
url += '/' + config.routeKeywords.tag + '/' + this.tagSlug;
|
|
}
|
|
|
|
if (this.authorSlug !== undefined) {
|
|
url += '/' + config.routeKeywords.author + '/' + this.authorSlug;
|
|
}
|
|
|
|
if (pageNum > 1) {
|
|
url += '/' + config.routeKeywords.page + '/' + pageNum;
|
|
}
|
|
|
|
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.
|
|
//
|
|
pageUrl = function (pageNum, options) {
|
|
errors.logWarn(i18n.t('warnings.helpers.page_url.isDeprecated'));
|
|
|
|
/*jshint unused:false*/
|
|
var self = this;
|
|
|
|
return page_url.call(self, pageNum, options);
|
|
};
|
|
|
|
module.exports = page_url;
|
|
module.exports.deprecated = pageUrl;
|