2014-10-10 18:54:07 +04:00
|
|
|
// # URL helper
|
|
|
|
// Usage: `{{url}}`, `{{url absolute="true"}}`
|
|
|
|
//
|
|
|
|
// Returns the URL for the current object scope i.e. If inside a post scope will return post permalink
|
|
|
|
// `absolute` flag outputs absolute URL, else URL is relative
|
|
|
|
|
2017-01-11 13:45:56 +03:00
|
|
|
var hbs = require('express-hbs'),
|
|
|
|
getMetaDataUrl = require('../data/meta/url');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2016-01-17 13:07:52 +03:00
|
|
|
function url(options) {
|
2017-01-11 13:45:56 +03:00
|
|
|
var absolute = options && options.hash.absolute,
|
|
|
|
url = getMetaDataUrl(this, absolute);
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2017-01-11 13:45:56 +03:00
|
|
|
url = encodeURI(decodeURI(url));
|
|
|
|
|
|
|
|
return new hbs.SafeString(url);
|
2016-01-17 13:07:52 +03:00
|
|
|
}
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
module.exports = url;
|