diff --git a/README.md b/README.md index b66f7db8..edd0805c 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,13 @@ The **NetForge** is a library that provides a user-friendly and intuitive user i - [Search](#search) - [View Site URL](#view-site-url) - [Grouping](#grouping) + - [Customizing the UI](#customizing-the-ui) + - [Main Layout Overriding](#main-layout-overriding) + - [Head Tag Overriding](#head-tag-overriding) - [Create Groups for Entities](#create-groups-for-entities) - [Configuration](#configuration) - [Headers Expansion](#headers-expansion) - [Exclude All Entities and Include Specific Only](#exclude-all-entities-and-include-specific-only) - - [Customizing the UI](#customizing-the-ui) - - [Main Layout Overriding](#main-layout-overriding) - [Customizing Entities](#customizing-entities) - [Fluent API](#fluent-api) - [Creating an Entity Configuration Class](#creating-an-entity-configuration-class) @@ -39,12 +40,14 @@ The **NetForge** is a library that provides a user-friendly and intuitive user i - [Rich Text Field](#rich-text-field) - [Image Properties](#image-properties) - [Configuration](#configuration-1) + - [Max image size](#max-image-size) - [Read-only Properties](#read-only-properties) - [Configuration](#configuration-2) - [String Truncate](#string-truncate) - [Configuration](#configuration-3) - [Multiline Text Field Property](#multiline-text-field-property) - [Configuration](#configuration-4) + - [License](#license) # How to Use @@ -197,6 +200,61 @@ The example of the custom component with navigation bar and footer: ``` +### Head Tag Overriding + +You can inject custom meta tags or page title into the head tag of the admin panel. + +```csharp +services.AddNetForge(optionsBuilder => +{ + optionsBuilder.SetCustomHeadType(typeof(CustomHead)); +}); +``` + +Example of injecting custom meta tags or a page title into the head tag of the admin panel. +```csharp +@using Microsoft.AspNetCore.Components.Web + +This is the custom page title. + +``` + +**Note:** If you are using a `Custom Layout`, you must add the dynamic component into the custom layout: + +```csharp +@using Saritasa.NetForge.Domain.Entities.Options +@inject AdminOptions AdminOptions; + + + @if (AdminOptions.CustomHeadType is not null) + { + + } + +``` + +Example: + +```csharp +@using MudBlazor +@using Saritasa.NetForge.Domain.Entities.Options +@using Microsoft.AspNetCore.Components.Web +@inherits Saritasa.NetForge.Blazor.Shared.AdminBaseLayout +@inject AdminOptions AdminOptions; + + + @if (AdminOptions.CustomHeadType is not null) + { + + } + + + + +... +... +``` + ### Create Groups for Entities Before assigning entities to specific groups, users need to define the groups to which the entities will belong. @@ -822,7 +880,7 @@ public required string Street { get; set; } ```csharp entityOptionsBuilder.ConfigureProperty(address => address.Street, builder => { - builder.SetIsMultiline(maxLines: 15); // sets the max lines value as 15 + builder.SetIsMultiline(maxLines: 15); // sets the max lines value as 15 }); ``` diff --git a/demo/Saritasa.NetForge.Demo/Startup.cs b/demo/Saritasa.NetForge.Demo/Startup.cs index bc22cba5..f4f00c2c 100644 --- a/demo/Saritasa.NetForge.Demo/Startup.cs +++ b/demo/Saritasa.NetForge.Demo/Startup.cs @@ -37,14 +37,14 @@ public void ConfigureServices(IServiceCollection services, IWebHostEnvironment e var connectionString = configuration.GetConnectionString("AppDatabase") ?? throw new ArgumentNullException("ConnectionStrings:AppDatabase", "Database connection string is not initialized"); - + services.AddDbContext(options => { options.UseNpgsql(connectionString).UseSnakeCaseNamingConvention(); }); services.AddAsyncInitializer(); services.AddHealthChecks().AddNpgSql(connectionString); - + // Identity. services.AddIdentity() .AddEntityFrameworkStores() diff --git a/src/Saritasa.NetForge.Blazor/App.razor b/src/Saritasa.NetForge.Blazor/App.razor index 570b23b1..902ab9c6 100644 --- a/src/Saritasa.NetForge.Blazor/App.razor +++ b/src/Saritasa.NetForge.Blazor/App.razor @@ -16,7 +16,7 @@ - + diff --git a/src/Saritasa.NetForge.Blazor/Domain/AdminOptionsBuilder.cs b/src/Saritasa.NetForge.Blazor/Domain/AdminOptionsBuilder.cs index 8f709bc0..a9213b91 100644 --- a/src/Saritasa.NetForge.Blazor/Domain/AdminOptionsBuilder.cs +++ b/src/Saritasa.NetForge.Blazor/Domain/AdminOptionsBuilder.cs @@ -276,4 +276,15 @@ public AdminOptionsBuilder SetCustomLayout(Type layoutType) options.CustomLayoutType = layoutType; return this; } + + /// + /// Sets the custom head type for the admin panel. + /// + /// The type of the custom head. + /// The current instance of . + public AdminOptionsBuilder SetCustomHeadType(Type headType) + { + options.CustomHeadType = headType; + return this; + } } diff --git a/src/Saritasa.NetForge.Blazor/Domain/Entities/Options/AdminOptions.cs b/src/Saritasa.NetForge.Blazor/Domain/Entities/Options/AdminOptions.cs index 3df66da8..542aad4a 100644 --- a/src/Saritasa.NetForge.Blazor/Domain/Entities/Options/AdminOptions.cs +++ b/src/Saritasa.NetForge.Blazor/Domain/Entities/Options/AdminOptions.cs @@ -90,4 +90,9 @@ public class AdminOptions /// The optional type of custom layout for the admin panel. /// public Type? CustomLayoutType { get; set; } + + /// + /// The optional type of custom head for the admin panel. + /// + public Type? CustomHeadType { get; set; } } diff --git a/src/Saritasa.NetForge.Blazor/Pages/Index.razor b/src/Saritasa.NetForge.Blazor/Pages/Index.razor index 012f1fda..6ed7a57e 100644 --- a/src/Saritasa.NetForge.Blazor/Pages/Index.razor +++ b/src/Saritasa.NetForge.Blazor/Pages/Index.razor @@ -3,4 +3,4 @@ @inject AdminOptions AdminOptions; @AdminOptions.AdminPanelHtmlTitle - + diff --git a/src/Saritasa.NetForge.Blazor/Shared/MainLayout.razor b/src/Saritasa.NetForge.Blazor/Shared/MainLayout.razor index 98c27627..4e0e3795 100644 --- a/src/Saritasa.NetForge.Blazor/Shared/MainLayout.razor +++ b/src/Saritasa.NetForge.Blazor/Shared/MainLayout.razor @@ -2,6 +2,13 @@ @inherits MainLayoutComponent @inject AdminOptions AdminOptions; + + @if (AdminOptions.CustomHeadType is not null) + { + + } + +