mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
658a6dd284
- the proxy should always be used to access other parts of Ghost, including the urlService etc - use consistent ES6 style for requires - minimise use of lodash where possible - remove circular dependency between proxy and template util - End goal here is to enforce that the only link between helpers + the rest of Ghost is the proxy
17 lines
594 B
JavaScript
17 lines
594 B
JavaScript
// # 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
|
|
|
|
const {SafeString, metaData} = require('./proxy');
|
|
const {getMetaDataUrl} = metaData;
|
|
|
|
module.exports = function url(options) {
|
|
var absolute = options && options.hash.absolute && options.hash.absolute !== 'false',
|
|
outputUrl = getMetaDataUrl(this, absolute);
|
|
|
|
outputUrl = encodeURI(decodeURI(outputUrl));
|
|
|
|
return new SafeString(outputUrl);
|
|
};
|