Toolbelt.Blazor.HeadElement.Abstractions
1.0.0
See the version list below for details.
dotnet add package Toolbelt.Blazor.HeadElement.Abstractions --version 1.0.0
NuGet\Install-Package Toolbelt.Blazor.HeadElement.Abstractions -Version 1.0.0
<PackageReference Include="Toolbelt.Blazor.HeadElement.Abstractions" Version="1.0.0" />
paket add Toolbelt.Blazor.HeadElement.Abstractions --version 1.0.0
#r "nuget: Toolbelt.Blazor.HeadElement.Abstractions, 1.0.0"
// Install Toolbelt.Blazor.HeadElement.Abstractions as a Cake Addin #addin nuget:?package=Toolbelt.Blazor.HeadElement.Abstractions&version=1.0.0 // Install Toolbelt.Blazor.HeadElement.Abstractions as a Cake Tool #tool nuget:?package=Toolbelt.Blazor.HeadElement.Abstractions&version=1.0.0
Blazor Head Element Helper
Summary
This components and services allows you to change the title of document and "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.
How to use
Installation
- Add package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement
- 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.
...
- Open
Toolbelt.Blazor.HeadElement
namespace in_Imports.razor
file.
@* This is "_Imports.razor" *@
...
@using Toolbelt.Blazor.HeadElement
A. Change the title of the document
- Markup
<Title>
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.
Note - IHeadElementHelper
You can do these tasks by using IHeadElementHelper
service instead of using <Title>
and <Meta>
components.
You can get the IHeadElementHelper
service instnace by "Dependency Injection" mechanism.
@inject IHeadElementHelper HeadElementHelper
@using static Toolbelt.Blazor.HeadElement.MetaElement
...
@code {
protected override async Task OnInitializedAsync()
{
await HeadElementHelper.SetTitleAsync("Wow!");
await HeadElementHelper.SetMetaElementsAsync(
ByName("description", "Foo bar..."),
ByProp("og:title", "WoW!")
);
...
B. Change "meta" elements
You can also add or override "meta" elements at runtime dynamically using <Meta>
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.
- Add
Toolbelt.Blazor.HeadElement.ServerPrerendering
package to your project like this.
dotnet add package Toolbelt.Blazor.HeadElement.ServerPrerendering
- Register "Head Element Server Prerendering" middleware at your server-side Blazor app's
Startup
, beforeapp.UseStaticFiles()
.
using Toolbelt.Blazor.Extensions.DependencyInjection; // <- Add this, and...
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseHeadElementServerPrerendering(); // <- Add this.
...
app.UseStaticFiles()
...
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 4.6.0)
- System.Threading.Tasks.Extensions (>= 4.5.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Toolbelt.Blazor.HeadElement.Abstractions:
Package | Downloads |
---|---|
Toolbelt.Blazor.HeadElement.Services
Head element support (change the document title, "meta" elements such as OGP, and "link" elements such as canonical url, favicon) for Blazor apps. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.1.0 | 51,779 | 3/28/2022 |
7.0.0 | 6,982 | 1/23/2022 |
1.5.0 | 65,584 | 1/10/2021 |
1.4.0 | 1,021 | 1/10/2021 |
1.3.0 | 1,291 | 1/9/2021 |
1.2.0 | 36,010 | 6/4/2020 |
1.2.0-beta | 518 | 5/29/2020 |
1.1.0.1 | 4,959 | 1/18/2020 |
1.0.0 | 1,466 | 11/1/2019 |
0.0.1-preview2.0.2 | 291 | 9/19/2019 |
0.0.1-preview1.0.1 | 284 | 9/12/2019 |