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

Using newer .net 8+ layout of Blazor without any cshtml files #55

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions src/NodeDev.Blazor.Server/App.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView>
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />

<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="_content/NodeDev.Blazor/styles.css" rel="stylesheet" />

<link href="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" rel="stylesheet" />

<link href="_content/Z.Blazor.Diagrams/style.min.css" rel="stylesheet" />
<link href="_content/Z.Blazor.Diagrams/default.styles.min.css" rel="stylesheet" />
</head>
<body style="width: 100vw; height: 100vh">

<Routes @rendermode="InteractiveServer" />

<script src="_content/BlazorMonaco/jsInterop.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>

<script src="_framework/blazor.web.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>

<script src="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>

<script src="_content/Z.Blazor.Diagrams/script.min.js"></script>
</body>
</html>
8 changes: 0 additions & 8 deletions src/NodeDev.Blazor.Server/Pages/_Host.cshtml

This file was deleted.

37 changes: 0 additions & 37 deletions src/NodeDev.Blazor.Server/Pages/_Layout.cshtml

This file was deleted.

15 changes: 7 additions & 8 deletions src/NodeDev.Blazor.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using NodeDev.Blazor.Server;
using NodeDev.Blazor.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

builder.Services.AddNodeDev();

Expand All @@ -20,11 +19,11 @@
app.UseHsts();
}

app.UseStaticFiles();
app.UseAntiforgery();

app.UseRouting();
app.UseStaticFiles();

app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();

app.Run();
12 changes: 12 additions & 0 deletions src/NodeDev.Blazor.Server/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView>
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
1 change: 1 addition & 0 deletions src/NodeDev.Blazor.Server/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.JSInterop
@using NodeDev.Blazor.Server
Loading