0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/frontend/helpers/url.js
Hannah Wolfe 658a6dd284 Cleaned all usages of proxy in helpers
- 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
2020-03-31 12:42:15 +01:00

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);
};