mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
10fc320cc8
no issue - In Ghost, 'context' means the page or section of a blog we're currently within when rendering a theme, e.g. 'post' or 'tag' or 'home'. - In handlebars 'context' refers to the blob of JSON that is tied to a template. - These two uses of the word 'context' have gotten very confusing, so I've removed all usage of 'context' within the Ghost handlebars helpers, EXCEPT where they actually refer to the current context (e.g. the is helper)
34 lines
753 B
JavaScript
34 lines
753 B
JavaScript
var config = require('../../config');
|
|
|
|
function getAssetUrl(path, isAdmin, minify) {
|
|
var output = '';
|
|
|
|
output += config.paths.subdir + '/';
|
|
|
|
if (!path.match(/^favicon\.ico$/) && !path.match(/^shared/) && !path.match(/^asset/)) {
|
|
if (isAdmin) {
|
|
output += 'ghost/';
|
|
} else {
|
|
output += 'assets/';
|
|
}
|
|
}
|
|
|
|
// Get rid of any leading slash on the path
|
|
path = path.replace(/^\//, '');
|
|
|
|
// replace ".foo" with ".min.foo" in production
|
|
if (minify) {
|
|
path = path.replace(/\.([^\.]*)$/, '.min.$1');
|
|
}
|
|
|
|
output += path;
|
|
|
|
if (!path.match(/^favicon\.ico$/)) {
|
|
output = output + '?v=' + config.assetHash;
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
module.exports = getAssetUrl;
|