mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
35e3e0708c
- The proxy is not a helper, we want the helpers folder to only include helpers - The proxy is also meant to be the interface to Ghost for the helpers, and we want to enforce that - This is a small step on the way
22 lines
580 B
JavaScript
22 lines
580 B
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`
|
|
//
|
|
// Returns the path to the specified asset.
|
|
const {SafeString, metaData, errors, i18n} = require('../services/proxy');
|
|
const get = require('lodash/get');
|
|
const {getAssetUrl} = metaData;
|
|
|
|
module.exports = function asset(path, options) {
|
|
const hasMinFile = get(options, 'hash.hasMinFile');
|
|
|
|
if (!path) {
|
|
throw new errors.IncorrectUsageError({
|
|
message: i18n.t('warnings.helpers.asset.pathIsRequired')
|
|
});
|
|
}
|
|
|
|
return new SafeString(
|
|
getAssetUrl(path, hasMinFile)
|
|
);
|
|
};
|