0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/services/routing/registry.js
kirrg001 87c01c131b 🐛 Fixed {{#is "index"}}
closes https://github.com/TryGhost/Ghost/issues/9674

- with dynamic routing the first collection get's the "index" context attached
- the index context signalises the main post listening route (first collection)
- this behaviour was present < 1.24 - we have to keep this behaviour
2018-06-14 11:53:13 +02:00

43 lines
810 B
JavaScript

const _ = require('lodash');
let routes = [];
let routers = {};
module.exports = {
setRoute(routerName, route) {
routes.push({route: route, from: routerName});
},
setRouter(name, router) {
routers[name] = router;
},
getAllRoutes() {
return _.cloneDeep(routes);
},
getRouter(name) {
return routers[name];
},
getFirstCollectionRouter() {
return _.find(routers, (router) => {
if (router.name === 'CollectionRouter' && router.firstCollection) {
return router;
}
return false;
});
},
resetAllRoutes() {
routes = [];
},
resetAllRouters() {
_.each(routers, (value) => {
value.reset();
});
routers = {};
}
};