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
|
|
|
|
|
2020-04-08 18:56:37 +03:00
|
|
|
const {SafeString, metaData} = require('../services/proxy');
|
2020-03-30 23:23:02 +03:00
|
|
|
const {getMetaDataUrl} = metaData;
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
module.exports = function url(options) {
|
2020-04-29 18:44:27 +03:00
|
|
|
const absolute = options && options.hash.absolute && options.hash.absolute !== 'false';
|
|
|
|
let 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);
|
|
|
|
};
|