I use following folder structure to organize my blazor wasm project:
Features
- Components
- Feature A
- Components
- Page1.razor
- Page2.razor
Index.razor
Shared
- MainLayout.razor
I've created a layout, that I want to use in most of the features.
I came up with following idea but I am struggling to implement this in blazor. SubPageLayout.razor:
@inherits LayoutComponentBase
@layout MainLayout
<div>
<span>@FeatureTitle</span>
@Menu
<div class="container">
<span>@PageTitle</span>
<div class="content">
@Body
</div>
</div>
</div>
Then I would create an Feature A/Index.razor page that uses the layout:
@page "/feature"
@layout SubPageLayout
<FeatureTitle>Feature A</FeatureTitle>
<Menu>
...
</Menu>
@Body
Then in Page1.razor:
@page "/feature/page-1"
<PageTitle>Page 1</PageTitle>
Content...
I have two related questions:
- What is the blazor-way to implement this nested layout?
- How can localhost/feature be redirected to localhost/feature/page? /feature in itself is just a wrapper providing a common layout and navigation for all the pages of that feature.
