2014-10-10 15:54:07 +01: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 16:56:37 +01:00
|
|
|
const {SafeString, metaData} = require('../services/proxy');
|
2020-03-30 21:23:02 +01:00
|
|
|
const {getMetaDataUrl} = metaData;
|
2014-10-10 15:54:07 +01:00
|
|
|
|
2017-04-04 17:07:35 +01:00
|
|
|
module.exports = function url(options) {
|
2020-04-29 16:44:27 +01:00
|
|
|
const absolute = options && options.hash.absolute && options.hash.absolute !== 'false';
|
|
|
|
let outputUrl = getMetaDataUrl(this, absolute);
|
2014-10-10 15:54:07 +01:00
|
|
|
|
2017-04-04 17:07:35 +01:00
|
|
|
outputUrl = encodeURI(decodeURI(outputUrl));
|
2017-01-11 10:45:56 +00:00
|
|
|
|
2017-04-04 17:07:35 +01:00
|
|
|
return new SafeString(outputUrl);
|
|
|
|
};
|