mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Absolute option for {{url}} helper
- pass absolute to {{url}} to get an absolute url rather than a relative one
This commit is contained in:
parent
1ff9550e1f
commit
552a25018f
1 changed files with 17 additions and 3 deletions
|
@ -44,11 +44,25 @@ coreHelpers = function (ghost) {
|
|||
return date;
|
||||
});
|
||||
|
||||
// ### URL helper
|
||||
//
|
||||
// *Usage example:*
|
||||
// `{{url}}`
|
||||
// `{{url absolute}}`
|
||||
//
|
||||
// Returns the URL for the current object context
|
||||
// i.e. If inside a post context will return post permalink
|
||||
// absolute flag outputs absolute URL, else URL is relative
|
||||
ghost.registerThemeHelper('url', function (context, options) {
|
||||
if (models.isPost(this)) {
|
||||
return "/" + this.slug;
|
||||
var output = '';
|
||||
|
||||
if (options && options.absolute) {
|
||||
output += ghost.config().env[process.NODE_ENV].url;
|
||||
}
|
||||
return '';
|
||||
if (models.isPost(this)) {
|
||||
output += "/" + this.slug;
|
||||
}
|
||||
return output;
|
||||
});
|
||||
|
||||
// ### Author Helper
|
||||
|
|
Loading…
Add table
Reference in a new issue