1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 16:07:34 +02:00

common: add routeName to component props in mapRoutes

This commit is contained in:
David Sevilla Martin
2020-05-03 10:48:33 -04:00
parent 717e8aa27e
commit b00eae1ce9
6 changed files with 9168 additions and 8329 deletions

View File

@@ -10,14 +10,15 @@ export default function mapRoutes(routes: object, basePath: string = ''): RouteD
const map = {};
for (const key in routes) {
if (!routes.hasOwnProperty(key)) continue;
const route = routes[key];
if (route.component) {
if (!route.component.attrs) route.component.attrs = {};
route.component.attrs.routeName = key;
}
map[basePath + route.path] = route.component;
map[basePath + route.path] = {
render() {
return m(route.component, { routeName: key });
},
};
}
return map;

View File

@@ -316,7 +316,7 @@ export default class IndexPage extends Page {
params.sort = sort;
}
m.route(app.route(this.props.routeName, params));
m.route.set(app.route(this.props.routeName, params));
}
/**