refactor: register markdown pipeline in common lib

This commit is contained in:
Oliver Booth 2024-03-02 03:23:10 +00:00
parent ab76264cd0
commit 97466ba84b
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
3 changed files with 11 additions and 14 deletions

View File

@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using OliverBooth.Common.Data.Blog;
using OliverBooth.Common.Data.Web.Users;
namespace OliverBooth.Api.Data;

View File

@ -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
/// <param name="collection">The <see cref="IServiceCollection" /> to add the service to.</param>
public static void AddCommonServices(this IServiceCollection collection)
{
collection.AddSingleton(provider => new MarkdownPipelineBuilder()
// .Use<TimestampExtension>()
.Use(new TemplateExtension(provider.GetRequiredService<ITemplateService>()))
.UseAdvancedExtensions()
.UseBootstrap()
.UseEmojiAndSmiley()
.UseSmartyPants()
.Build());
collection.AddDbContextFactory<BlogContext>();
collection.AddDbContextFactory<WebContext>();

View File

@ -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<TimestampExtension>()
.Use(new TemplateExtension(provider.GetRequiredService<ITemplateService>()))
.UseAdvancedExtensions()
.UseBootstrap()
.UseEmojiAndSmiley()
.UseSmartyPants()
.Build());
builder.Services.AddApiVersioning(options =>
{
options.AssumeDefaultVersionWhenUnspecified = true;