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-04-04 19:07:35 +03:00
|
|
|
var proxy = require('./proxy'),
|
|
|
|
SafeString = proxy.SafeString,
|
|
|
|
getMetaDataUrl = proxy.metaData.getMetaDataUrl;
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
module.exports = function url(options) {
|
2017-01-11 13:45:56 +03:00
|
|
|
var absolute = options && options.hash.absolute,
|
2017-04-04 19:07:35 +03:00
|
|
|
outputUrl = getMetaDataUrl(this, absolute);
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
outputUrl = encodeURI(decodeURI(outputUrl));
|
2017-01-11 13:45:56 +03:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
return new SafeString(outputUrl);
|
|
|
|
};
|