Ghost/ghost/admin/helpers/ghost-paths.js

35 lines
1008 B
JavaScript
Raw Normal View History

// Handlebars Helper {{gh-path}}
// Usage: Assume 'http://www.myghostblog.org/myblog/'
// {{gh-path}} or {{gh-path blog}} for Ghosts root (/myblog/)
// {{gh-path admin}} for Ghosts admin root (/myblog/ghost/)
// {{gh-path api}} for Ghosts api root (/myblog/ghost/api/v0.1/)
// {{gh-path 'admin' '/assets/hi.png'}} for resolved url (/myblog/ghost/assets/hi.png)
import ghostPaths from 'ghost/utils/ghost-paths';
function ghostPathsHelper(path, url) {
var base;
switch (path.toString()) {
case 'blog':
base = ghostPaths().blogRoot;
break;
case 'admin':
base = ghostPaths().adminRoot;
break;
case 'api':
base = ghostPaths().apiRoot;
break;
default:
base = ghostPaths().blogRoot;
break;
}
if (url && url.length > 0) {
base = base + url;
}
return new Ember.Handlebars.SafeString(base);
}
export default ghostPathsHelper;