Ghost/core/client/helpers/ghost-paths.js
2014-09-24 20:06:42 -05:00

34 lines
974 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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';
export default function (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);
}