Add support for multiple routes in a single page#59
Conversation
✅ Deploy Preview for blazorstatic ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
tesar-tech
left a comment
There was a problem hiding this comment.
Thank you,
Please add it to some page in the demo website so we can "test".
Also make sure it works without the @page directive. (by specifying the attribute the "classic" way).
| var attr = (RouteAttribute)attributes[i]; | ||
| if(!attr.Template.Contains('{')) | ||
| { | ||
| routes[i] = attr.Template; |
There was a problem hiding this comment.
so this will potentially create an array with
- [0] null
- [1] something
(right??)
Can we just return only the non null entries? Or change the return type?
There was a problem hiding this comment.
that's actually filtered in the function above
return assembly.ExportedTypes
.Where(t => t.IsSubclassOf(typeof(ComponentBase)))
.SelectMany(GetRouteFromComponent)
.OfType<string>() // only return non null stringsThere was a problem hiding this comment.
I am not afraid about that, but about GetRouteFromComponent returning the wrong type.
It should be string?[].
I don't understand why ide (at least rider) isn't yelling at me with its yellow squiggly lines, but it should be that.
There was a problem hiding this comment.
btw, why not something like
component
.GetCustomAttributes(typeof(RouteAttribute), inherit: false)
.OfType<RouteAttribute>()
.Where(attr => !attr.Template.Contains('{'))
.Select(attr => attr.Template)
.ToArray();
less lines, clean, always returns string[]
There was a problem hiding this comment.
I honestly don't know, but i didn't have any instance of GetRouteFromComponent returning an array containing a null value
There was a problem hiding this comment.
I guess that would happen if you have
@page "/mypage/{myparam}"
@page "/mypage/"
|
For the demo should it be a page added to the |
Yes, exactly. |
|
Done, i added a bullet point in the docs page that links to the demo, I'm not that good at web dev so I just made a basic page showing how it works. Also whether to use |
|
Good, thank you. Soon on nuget. |
Add support for pages that have multiple routes, and some performance improvements.
example:
Previously only the first route (
/blogsin this example) will be generated.This is can be useful for adding translations to a site (i'm working on an example)