mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
03b0e06b9e
closes #4144 - made contributors template use the `gh-path` helper - Removing blogRoot from application.js - made error image use the `gh-path` helper
44 lines
927 B
JavaScript
44 lines
927 B
JavaScript
var makeRoute = function (root, args) {
|
|
var parts = Array.prototype.slice.call(args, 0).join('/'),
|
|
route = [root, parts].join('/');
|
|
|
|
if (route.slice(-1) !== '/') {
|
|
route += '/';
|
|
}
|
|
|
|
return route;
|
|
};
|
|
|
|
|
|
function ghostPaths() {
|
|
var path = window.location.pathname,
|
|
subdir = path.substr(0, path.search('/ghost/')),
|
|
adminRoot = subdir + '/ghost',
|
|
apiRoot = subdir + '/ghost/api/v0.1';
|
|
|
|
function assetUrl(src) {
|
|
return subdir + src;
|
|
}
|
|
|
|
return {
|
|
subdir: subdir,
|
|
blogRoot: subdir + '/',
|
|
adminRoot: adminRoot,
|
|
apiRoot: apiRoot,
|
|
|
|
url: {
|
|
admin: function () {
|
|
return makeRoute(adminRoot, arguments);
|
|
},
|
|
|
|
api: function () {
|
|
return makeRoute(apiRoot, arguments);
|
|
},
|
|
|
|
asset: assetUrl
|
|
}
|
|
};
|
|
}
|
|
|
|
export default ghostPaths;
|