diff --git a/OliverBooth.Blog/Program.cs b/OliverBooth.Blog/Program.cs index d2013a7..8d28aea 100644 --- a/OliverBooth.Blog/Program.cs +++ b/OliverBooth.Blog/Program.cs @@ -5,7 +5,6 @@ using OliverBooth.Common; using OliverBooth.Common.Extensions; using OliverBooth.Common.Services; using Serilog; -using X10D.Hosting.DependencyInjection; Log.Logger = new LoggerConfiguration() .WriteTo.Console() @@ -17,6 +16,7 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true); builder.Logging.ClearProviders(); builder.Logging.AddSerilog(); +builder.Services.AddMarkdownPipeline(); builder.Services.ConfigureOptions(); builder.Services.AddDbContextFactory(); builder.Services.AddSingleton(); diff --git a/OliverBooth.Common/Extensions/ServiceCollectionExtensions.cs b/OliverBooth.Common/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..d45765b --- /dev/null +++ b/OliverBooth.Common/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,28 @@ +using Markdig; +using Microsoft.Extensions.DependencyInjection; +using OliverBooth.Common.Markdown; +using OliverBooth.Common.Services; + +namespace OliverBooth.Common.Extensions; + +/// +/// Extension methods for . +/// +public static class ServiceCollectionExtensions +{ + /// + /// Adds the Markdown pipeline to the . + /// + /// The . + /// The . + public static IServiceCollection AddMarkdownPipeline(this IServiceCollection serviceCollection) + { + return serviceCollection.AddSingleton(provider => new MarkdownPipelineBuilder() + .Use(new TemplateExtension(provider.GetRequiredService())) + .UseAdvancedExtensions() + .UseBootstrap() + .UseEmojiAndSmiley() + .UseSmartyPants() + .Build()); + } +} diff --git a/OliverBooth/Program.cs b/OliverBooth/Program.cs index 243b09b..96307d7 100644 --- a/OliverBooth/Program.cs +++ b/OliverBooth/Program.cs @@ -1,10 +1,7 @@ -using Markdig; using OliverBooth.Common; using OliverBooth.Common.Extensions; -using OliverBooth.Common.Markdown; using OliverBooth.Common.Services; using OliverBooth.Data; -using OliverBooth.Markdown.Timestamp; using OliverBooth.Services; using Serilog; @@ -18,18 +15,9 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true); builder.Logging.ClearProviders(); builder.Logging.AddSerilog(); +builder.Services.AddMarkdownPipeline(); builder.Services.ConfigureOptions(); builder.Services.AddSingleton(); - -builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder() - .Use() - .Use(new TemplateExtension(provider.GetRequiredService())) - .UseAdvancedExtensions() - .UseBootstrap() - .UseEmojiAndSmiley() - .UseSmartyPants() - .Build()); - builder.Services.AddDbContextFactory(); builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); builder.Services.AddControllersWithViews();