Toolbelt.Blazor.HeadElement.Services 0.0.1-preview2.0.2

Head element support (change the document title, "meta" elements such as OGP) for Blazor apps.

This is a prerelease version of Toolbelt.Blazor.HeadElement.Services.
This package has a SemVer 2.0.0 package version.
This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3.0 and above. Read more
Install-Package Toolbelt.Blazor.HeadElement.Services -Version 0.0.1-preview2.0.2
dotnet add package Toolbelt.Blazor.HeadElement.Services --version 0.0.1-preview2.0.2
<PackageReference Include="Toolbelt.Blazor.HeadElement.Services" Version="0.0.1-preview2.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Toolbelt.Blazor.HeadElement.Services --version 0.0.1-preview2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Blazor Head Element Helper NuGet Package

Summary

This component and services allows you to change the title of document, "meta" elements such as OGP, on your Blazor app.

This package supports both seiver-side Blazor and client-side Blazor WebAssembly app.

And also supports server-side pre-rendering on your server-side Blazor app.

NOTICE! - This is "Preview" Release

This package is "preview" release at this time.

Some implementations of this packages depends on internals of ASP.NET Core Components.

~~Especially, server-side pre-rendering is very slow and stressfull, because it captures all requests and buffering all responses on memory.~~
19 Sep, 2019 - Fixed this issue at v.0.0.1-preview2.

How to use

Installation

  1. Add package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement --version 0.0.2-preview2.0.2
  1. Register "Head Element Helper" service at your Blazor app's Startup.
using Toolbelt.Blazor.Extensions.DependencyInjection; // <- Add this, and...

public class Startup
{
  public void ConfigureServices(IServiceCollection services)
  {
    services.AddHeadElementHelper(); // <- Add this.
    ...
  1. Open Toolbelt.Blazor.HeadElement namespace in _Imports.razor file.
@* This is "_Imports.razor" *@
...
@using Toolbelt.Blazor.HeadElement

A. Change the title of document

  1. Markup &lt;Title&gt; component in your .razor file.
@* This is "Pages/Counter.razor" *@
@page "/counter"

<Title>Counter(@currentCount) - Server Side App</Title>

The title of document will be changed.

fig1

B. Change "meta" elements

You can also add or override "meta" elements at runtime dynamically using &lt;Meta&gt; component like this.

@* This is "Pages/Counter.razor" *@
@page "/counter"

<Meta Property="ogp:title" Content="Counter" />

C. Server-side pre-rendering support

If you want to get srever-side pre-rendering support, do this.

  1. Add Toolbelt.Blazor.HeadElement.ServerPrerendering package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement.ServerPrerendering --version 0.0.1-preview2.0.2
  1. Register "Head Element Server Prerendering" middleware at your server-side Blazor app's Startup, before appUseStaticFiles().
using Toolbelt.Blazor.Extensions.DependencyInjection; // <- Add this, and...

public class Startup
{
  public void Configure(IApplicationBuilder app)
  {
    app.UseHeadElementServerPrerendering(); // <- Add this.
    ...
    app.UseStaticFiles()
    ...

fig2

License

Mozilla Public License Version 2.0

Blazor Head Element Helper NuGet Package

Summary

This component and services allows you to change the title of document, "meta" elements such as OGP, on your Blazor app.

This package supports both seiver-side Blazor and client-side Blazor WebAssembly app.

And also supports server-side pre-rendering on your server-side Blazor app.

NOTICE! - This is "Preview" Release

This package is "preview" release at this time.

Some implementations of this packages depends on internals of ASP.NET Core Components.

~~Especially, server-side pre-rendering is very slow and stressfull, because it captures all requests and buffering all responses on memory.~~
19 Sep, 2019 - Fixed this issue at v.0.0.1-preview2.

How to use

Installation

  1. Add package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement --version 0.0.2-preview2.0.2
  1. Register "Head Element Helper" service at your Blazor app's Startup.
using Toolbelt.Blazor.Extensions.DependencyInjection; // <- Add this, and...

public class Startup
{
  public void ConfigureServices(IServiceCollection services)
  {
    services.AddHeadElementHelper(); // <- Add this.
    ...
  1. Open Toolbelt.Blazor.HeadElement namespace in _Imports.razor file.
@* This is "_Imports.razor" *@
...
@using Toolbelt.Blazor.HeadElement

A. Change the title of document

  1. Markup &lt;Title&gt; component in your .razor file.
@* This is "Pages/Counter.razor" *@
@page "/counter"

<Title>Counter(@currentCount) - Server Side App</Title>

The title of document will be changed.

fig1

B. Change "meta" elements

You can also add or override "meta" elements at runtime dynamically using &lt;Meta&gt; component like this.

@* This is "Pages/Counter.razor" *@
@page "/counter"

<Meta Property="ogp:title" Content="Counter" />

C. Server-side pre-rendering support

If you want to get srever-side pre-rendering support, do this.

  1. Add Toolbelt.Blazor.HeadElement.ServerPrerendering package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement.ServerPrerendering --version 0.0.1-preview2.0.2
  1. Register "Head Element Server Prerendering" middleware at your server-side Blazor app's Startup, before appUseStaticFiles().
using Toolbelt.Blazor.Extensions.DependencyInjection; // <- Add this, and...

public class Startup
{
  public void Configure(IApplicationBuilder app)
  {
    app.UseHeadElementServerPrerendering(); // <- Add this.
    ...
    app.UseStaticFiles()
    ...

fig2

License

Mozilla Public License Version 2.0

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.1-preview2.0.2 27 9/19/2019
0.0.1-preview1.0.1 34 9/12/2019