But how to set up a catch-all route? A google search found nothing except links into the Aurelia source code. A request on the gitter channel was not answered. So I dug through the source and found the answer myself (I admit, asking on gitter was cheating - I should have just searched the source in the first place).
You can add a catch-all by calling mapUnknownRoutes on the original config object. So my configureRouter has the one route, and the call to mapUnknowRoutes to set the view model that handles unknown routes. In my case, it looks kinda like this:
configureRouter(config, router) { config.title = 'Wow! What a site'; config.map([ { route: [ 'entry/:id'], moduleId: 'public/entry' } ]); config.mapUnknownRoutes('public/404'); }My 404 view model is empty, and 404.html has the page I want everyone to see.
Simple.
No comments:
Post a Comment