From 97466ba84bbe7045f961c257f4945d2924cfc061 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 2 Mar 2024 03:23:10 +0000 Subject: [PATCH] refactor: register markdown pipeline in common lib --- OliverBooth.Api/Data/Author.cs | 1 - .../Extensions/DependencyInjectionExtensions.cs | 11 +++++++++++ OliverBooth/Program.cs | 13 ------------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/OliverBooth.Api/Data/Author.cs b/OliverBooth.Api/Data/Author.cs index 0d0b73b..b5d9da8 100644 --- a/OliverBooth.Api/Data/Author.cs +++ b/OliverBooth.Api/Data/Author.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OliverBooth.Common.Data.Blog; using OliverBooth.Common.Data.Web.Users; namespace OliverBooth.Api.Data; diff --git a/OliverBooth.Common/Extensions/DependencyInjectionExtensions.cs b/OliverBooth.Common/Extensions/DependencyInjectionExtensions.cs index a383e71..b913985 100644 --- a/OliverBooth.Common/Extensions/DependencyInjectionExtensions.cs +++ b/OliverBooth.Common/Extensions/DependencyInjectionExtensions.cs @@ -1,6 +1,8 @@ +using Markdig; using Microsoft.Extensions.DependencyInjection; using OliverBooth.Common.Data.Blog; using OliverBooth.Common.Data.Web; +using OliverBooth.Common.Markdown.Template; using OliverBooth.Common.Services; using X10D.Hosting.DependencyInjection; @@ -17,6 +19,15 @@ public static class DependencyInjectionExtensions /// The to add the service to. public static void AddCommonServices(this IServiceCollection collection) { + collection.AddSingleton(provider => new MarkdownPipelineBuilder() + // .Use() + .Use(new TemplateExtension(provider.GetRequiredService())) + .UseAdvancedExtensions() + .UseBootstrap() + .UseEmojiAndSmiley() + .UseSmartyPants() + .Build()); + collection.AddDbContextFactory(); collection.AddDbContextFactory(); diff --git a/OliverBooth/Program.cs b/OliverBooth/Program.cs index ff75009..0043cfc 100644 --- a/OliverBooth/Program.cs +++ b/OliverBooth/Program.cs @@ -3,11 +3,7 @@ using Asp.Versioning; using AspNetCore.ReCaptcha; using FluentFTP; using FluentFTP.Logging; -using Markdig; using OliverBooth.Common.Extensions; -using OliverBooth.Common.Markdown.Template; -using OliverBooth.Common.Services; -using OliverBooth.Markdown.Timestamp; using OliverBooth.Services; using Serilog; using Serilog.Extensions.Logging; @@ -25,15 +21,6 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true); builder.Logging.ClearProviders(); builder.Logging.AddSerilog(); -builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder() - .Use() - .Use(new TemplateExtension(provider.GetRequiredService())) - .UseAdvancedExtensions() - .UseBootstrap() - .UseEmojiAndSmiley() - .UseSmartyPants() - .Build()); - builder.Services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true;