Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include url for default routes within match #90

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

alexanderknapstein
Copy link

@alexanderknapstein alexanderknapstein commented Feb 26, 2019

Dear @jthoms1 ,

we make heavily use of the route-switch but not only for not-found-pages, but for dynamic loaded content without assigning every route to a specific component. So in our case it would be helfpul to include the current "match" within the match object.

example:

<stencil-router>
    <stencil-route-switch>
        <stencil-route url='/home' component='il-home' title='home'></stencil-route>
        <stencil-route component='site-loader' title='site'></stencil-route>
    </stencil-route-switch>
</stencil-router>

the match result (@prop() match: MatchResults;) for all default routes (e.g. /some/url) looks like this:

{path: "/", url: "/", isExact: true, params: {…}}

which is not helpful in a fallback case to load any dynamic data. With my suggestion the match result will contain the current url, which can be consumed within the route component:

{path: "/some/url", url: "/some/url", isExact: true, params: {…}}

Would be cool, if you could merge that.
Thanx /Alex

@alexanderknapstein
Copy link
Author

Any chance of merging this?

@DominicBoettger
Copy link

until merge it's available as @inspirationlabs/router

@bitflower
Copy link
Contributor

Can you elaborate a bit more on the use case? Does it deal with nested / child routes requiring to be setup with full absolute paths? I have the use case that I dynamically build nested child routes and would love the created children to „inherit“ their route from the parent.

@DominicBoettger
Copy link

added compat to stencil one

@DominicBoettger
Copy link

@bitflower It's not adding such a feature. It makes it just easier to get the current match when using pages which are from top to bottom dynamic. In our case they are driven by a CMS backend and there is no real routing logic except a default match rule in stencil and we validate against the backend as soon as the current route changes and load the data from the backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants