mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
299b59385b
closes #2851 - adds asset paths to ghostPaths as we don't have an asset helper - sends any invalid routes to 404
36 lines
973 B
JavaScript
36 lines
973 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/'));
|
|
|
|
return {
|
|
subdir: subdir,
|
|
blogRoot: subdir + '/',
|
|
adminRoot: subdir + '/ghost',
|
|
apiRoot: subdir + '/ghost/api/v0.1',
|
|
userImage: subdir + '/assets/img/user-image.png',
|
|
errorImageSrc: subdir + '/ghost/img/404-ghost@2x.png',
|
|
errorImageSrcSet: subdir + '/ghost/img/404-ghost.png 1x, ' + subdir + '/ghost/img/404-ghost@2x.png 2x',
|
|
|
|
adminUrl: function () {
|
|
return makeRoute(this.adminRoot, arguments);
|
|
},
|
|
|
|
apiUrl: function () {
|
|
return makeRoute(this.apiRoot, arguments);
|
|
}
|
|
};
|
|
}
|
|
|
|
export default ghostPaths;
|