Closed LasseRosenow closed 5 years ago
Hi,
This is a great suggestion - I've just got some testing to do on an update that would include this feature, but it should be in by tonight/tomorrow morning. I'll leave a comment here when it's updated!
This feature has now been added in version 0.4.3 - closing this issue. Give it a try and let me know how you get on!
Thanks a lot thats pretty nice :)
But there is just a small thing I realized: It seems like you have to put the DefaultRoute element as the last element. If you don't do so it will always be shown. Is that intended behavior?
Yes that is the intended behaviour - all other routes need to be mounted before the DefaultRoute so it knows which routes are being used in your app. I'll update the documentation so that's a bit clearer. Thanks again!
Okay yeah I think updating the docs should do the job. Thanks a lot. I really didn't expect this to get sorted out by you so fast :)
I really like this library and would like to implement it into my project, but I don't see a way to implement a default route for every path that is not defined in my routing.
Let's say I have this routing:
const Router = () => html
${new Route('/', () => Home(), true).mount()} ${new Route('/home', () => Home(), true).mount()} ${new Route('/news', () => News(), true).mount()} ``But if if someone goes to "/fancypath" I would like to display something like 404 or just the home page. Can you think of any way to implement this specific behavior?