Support external routes in router configuration
See original GitHub issueI’m submitting a feature request
When building an app that links to external/legacy pages, it would be really handy if the URL’s for those external pages could be configured and generated the same way as the app routes.
Example:
public configureRouter(config: RouterConfiguration, router: AppRouter): void
{
config.options.pushState = true;
config.map(
[
{ route: "/", name: "home", moduleId: "./home", nav: true, title: "Home" },
// External route
{ route: "http://other-domain.com/:some-parameter", name: "external", title: "External", nav: true }
]);
}
The idea is, that routes starting with http://
or https://
would be used as-is, without prepending the base URL of the app. When navigating to the route, the browser location should just be set, instead of replaced, thus navigating out of the app. The route-href
attribute would also need to be aware of this, so it sets the correct value for href
.
The reason it would be nice to have it as part of the router configuration, is that it would allow us to generate navigation links, and have the external routes mixed in between the app routes. It would also allow us to generate those external URL’s, with parameters, based on the route name, thus keeping the route definitions in one place.
Thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:16 (6 by maintainers)
I’d love to see how you guys use it. Because from where I’m standing I don’t see the use case for having a route for external link might as well be
href="http://domain/path/${param1}/path/${param2}"
or<a href="http://aurelia.io/${'docs'}">read me (-:</a>
It will also be clearer for those who will read this, that the link is externalWould love to know what am I missing
I just tried this in one of the skeletons. I added a
route: 'http://www.somedomain.com'
and it worked. So I assume it has been patched in ?