Skip to content

Commit d6601c2

Browse files
committed
Update README to prepare official release
1 parent 49185a9 commit d6601c2

File tree

1 file changed

+14
-65
lines changed

1 file changed

+14
-65
lines changed

README.md

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# BlazorWasmPreRendering.Build [![NuGet Package](https://img.shields.io/nuget/v/BlazorWasmPreRendering.Build.svg)](https://www.nuget.org/packages/BlazorWasmPreRendering.Build/)
1+
# BlazorWasmPreRendering.Build
2+
3+
[![NuGet Package](https://img.shields.io/nuget/v/BlazorWasmPreRendering.Build.svg)](https://www.nuget.org/packages/BlazorWasmPreRendering.Build/) [![Discord](https://img.shields.io/discord/798312431893348414?style=flat&logo=discord&logoColor=white&label=Blazor%20Community&labelColor=5865f2&color=gray)](https://discord.com/channels/798312431893348414/1202165955900473375)
24

35
## 📝Summary
46

@@ -17,7 +19,7 @@ This will help make the contents of your Blazor WebAssembly static apps findable
1719
Install this package to your Blazor WebAssembly project.
1820

1921
```
20-
dotnet add package BlazorWasmPreRendering.Build --prerelease
22+
dotnet add package BlazorWasmPreRendering.Build
2123
```
2224

2325
Basically, **that's all**.
@@ -28,56 +30,14 @@ Basically, **that's all**.
2830

2931
### Services registration
3032

31-
If you are registering any services (except HttpClient that isn't specially configured) to the service provider at the startup of your Blazor WebAssembly app, please extract that process to the static method named `static void ConfigureServices(IServiceCollection services, string baseAddress)`.
32-
33-
```csharp
34-
public class Program
35-
{
36-
public static async Task Main(string[] args)
37-
{
38-
var builder = WebAssemblyHostBuilder.CreateDefault(args);
39-
builder.RootComponents.Add<App>("#app");
40-
41-
// 👇 Extract service registration...
42-
services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });
43-
services.AddScoped<IFoo, MyFoo>();
44-
45-
await builder.Build().RunAsync();
46-
}
47-
}
48-
```
49-
50-
```csharp
51-
public class Program
52-
{
53-
public static async Task Main(string[] args)
54-
{
55-
var builder = WebAssemblyHostBuilder.CreateDefault(args);
56-
builder.RootComponents.Add<App>("#app");
57-
58-
ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress);
59-
60-
await builder.Build().RunAsync();
61-
}
62-
63-
// 👇 ... to this named static method.
64-
private static void ConfigureServices(IServiceCollection services, string baseAddress)
65-
{
66-
services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });
67-
services.AddScoped<IFoo, MyFoo>();
68-
}
69-
}
70-
```
71-
72-
And, if you implement the entry point as C# 9 top-level statement style, then you have to also extract the service-registration process to the static local function named `static void ConfigureServices(IServiceCollection services, string baseAddress)`.
73-
74-
> _**NOTICE:** The "ConfigureServices" local function must be **"static"** local function._
33+
In the `Program.cs` of your Blazor WebAssembly app, you must extract the service registration part into the static local function named `static void ConfigureServices(IServiceCollection services, string baseAddress)`, like below.
7534

7635
```csharp
77-
// The "Program.cs" that is C# 9 top-level statement style entry point.
36+
// Program.cs
7837
7938
var builder = WebAssemblyHostBuilder.CreateDefault(args);
8039
builder.RootComponents.Add<App>("#app");
40+
builder.RootComponents.Add<HeadOutlet>("head::after");
8141

8242
ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress);
8343

@@ -91,15 +51,13 @@ static void ConfigureServices(IServiceCollection services, string baseAddress)
9151
}
9252
```
9353

94-
> _Aside: C# 9 top-level statement style entry point can be used for only .NET6 or above._
54+
This package calls the `ConfigureServices(...)` static local function inside of your Blazor WebAssembly app when the pre-rendering process starts if that function exists.
9555

96-
This package calls the `ConfigureServices()` static method (or static local function) inside of your Blazor WebAssembly app when pre-renders it if that method exists.
56+
This is important for your Blazor WebAssembly components to work fine in the pre-rendering process.
9757

98-
This is important to your Blazor WebAssembly components work fine in the pre-rendering process.
58+
#### Note: other arguments of ConfigureServices() function
9959

100-
#### Note: other arguments of ConfigureServices() method
101-
102-
The `ConfigureServices()` method can also have an `IConfiguration` argument reflected with the contents of the `wwwroot/appsetting.json` JSON file.
60+
The `ConfigureServices(...)` static local function can also have an `IConfiguration` argument that reflects the contents of the `wwwroot/appsetting.json` JSON file.
10361

10462
### Root component type and selector
10563

@@ -235,7 +193,7 @@ To support that case, please **set the URL path list that you want to fetch expl
235193

236194
As you may know, this package is based on the standard ASP.NET Core Blazor server-side prerendering support.
237195

238-
- See also: ["Prerender and integrate ASP.NET Core Razor components | Microsoft Docs"](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-6.0&pivots=webassembly)
196+
- See also: ["Prerender and integrate ASP.NET Core Razor components | Microsoft Learn"](https://learn.microsoft.com/aspnet/core/blazor/components/prerendering-and-integration?pivots=webassembly)
239197

240198
By default, the render mode of prerendering is `Static`.
241199
And, **you can specify the render mode to `WebAssemblyPrerendered` via the `BlazorWasmPrerenderingMode` MSBuild property** if you want.
@@ -275,7 +233,7 @@ if (!builder.RootComponents.Any())
275233

276234
That is because the root component types and their insertion positions are specified inside of the prerendered HTML contents, not inside of your C# code when the render mode is `WebAssemblyPrerendered`.
277235

278-
Moreover, on .NET 6, you can also use the **"persisting prerendered state"** feature.
236+
Moreover, you can also use the **"persisting prerendered state"** feature.
279237

280238
When the render mode is `WebAssemblyPrerendered`, this package injects the `<persist-component-state />` tag helper into the fallback page.
281239

@@ -452,19 +410,10 @@ During the prerendering process is running, developers can investigate it.
452410
## 🔗Appendix
453411

454412
- If you would like to **change a title or any meta elements** for each page in your Blazor WebAssembly app, I recommend using the [**"Blazor Head Element Helper"** ![NuGet Package](https://img.shields.io/nuget/v/Toolbelt.Blazor.HeadElement.svg)](https://www.nuget.org/packages/Toolbelt.Blazor.HeadElement/) NuGet package.
455-
- Since the ver.1.0.0 preview 8 of this package, **the .NET 6 `<PageTitle>` and `<HeadContent>` components** are also statically pre-rendered properly.
413+
- **The `<PageTitle>` and `<HeadContent>` components** are also statically pre-rendered properly.
456414
- If you would like to deploy your Blazor WebAssembly app to **GitHub Pages**, I recommend using the [**"Publish SPA for GitHub Pages"** ![NuGet Package](https://img.shields.io/nuget/v/PublishSPAforGitHubPages.Build.svg)](https://www.nuget.org/packages/PublishSPAforGitHubPages.Build/) NuGet package.
457415
- The **["Awesome Blazor Browser"](https://jsakamoto.github.io/awesome-blazor-browser/)** site is one of a good showcase of this package. That site is republishing every day by GitHub Actions with pre-rendering powered by this package.
458416

459-
## ⚠️Notice
460-
461-
This package is now experimental stage.
462-
463-
We can expect this package will work fine with a simple Blazor WebAssembly project.
464-
But I'm not sure this package works fine even with a complicated real-world Blazor WebAssembly project at this time.
465-
466-
I welcome to fork and improve this project on your hand.
467-
468417
## 🎉Release notes
469418

470419
[Release notes](https://github.com/jsakamoto/BlazorWasmPreRendering.Build/blob/master/RELEASE-NOTES.txt)

0 commit comments

Comments
 (0)