refactor: use shared Markdig pipeline
This commit is contained in:
parent
a84f537dc1
commit
f878bff8f3
|
@ -5,7 +5,6 @@ using OliverBooth.Common;
|
||||||
using OliverBooth.Common.Extensions;
|
using OliverBooth.Common.Extensions;
|
||||||
using OliverBooth.Common.Services;
|
using OliverBooth.Common.Services;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using X10D.Hosting.DependencyInjection;
|
|
||||||
|
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.WriteTo.Console()
|
.WriteTo.Console()
|
||||||
|
@ -17,6 +16,7 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true);
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
builder.Logging.AddSerilog();
|
builder.Logging.AddSerilog();
|
||||||
|
|
||||||
|
builder.Services.AddMarkdownPipeline();
|
||||||
builder.Services.ConfigureOptions<OliverBoothConfigureOptions>();
|
builder.Services.ConfigureOptions<OliverBoothConfigureOptions>();
|
||||||
builder.Services.AddDbContextFactory<BlogContext>();
|
builder.Services.AddDbContextFactory<BlogContext>();
|
||||||
builder.Services.AddSingleton<IBlogPostService, BlogPostService>();
|
builder.Services.AddSingleton<IBlogPostService, BlogPostService>();
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
using Markdig;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using OliverBooth.Common.Markdown;
|
||||||
|
using OliverBooth.Common.Services;
|
||||||
|
|
||||||
|
namespace OliverBooth.Common.Extensions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for <see cref="IServiceCollection" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the Markdown pipeline to the <see cref="IServiceCollection" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceCollection">The <see cref="IServiceCollection" />.</param>
|
||||||
|
/// <returns>The <see cref="IServiceCollection" />.</returns>
|
||||||
|
public static IServiceCollection AddMarkdownPipeline(this IServiceCollection serviceCollection)
|
||||||
|
{
|
||||||
|
return serviceCollection.AddSingleton(provider => new MarkdownPipelineBuilder()
|
||||||
|
.Use(new TemplateExtension(provider.GetRequiredService<ITemplateService>()))
|
||||||
|
.UseAdvancedExtensions()
|
||||||
|
.UseBootstrap()
|
||||||
|
.UseEmojiAndSmiley()
|
||||||
|
.UseSmartyPants()
|
||||||
|
.Build());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
using Markdig;
|
|
||||||
using OliverBooth.Common;
|
using OliverBooth.Common;
|
||||||
using OliverBooth.Common.Extensions;
|
using OliverBooth.Common.Extensions;
|
||||||
using OliverBooth.Common.Markdown;
|
|
||||||
using OliverBooth.Common.Services;
|
using OliverBooth.Common.Services;
|
||||||
using OliverBooth.Data;
|
using OliverBooth.Data;
|
||||||
using OliverBooth.Markdown.Timestamp;
|
|
||||||
using OliverBooth.Services;
|
using OliverBooth.Services;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
|
@ -18,18 +15,9 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true);
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
builder.Logging.AddSerilog();
|
builder.Logging.AddSerilog();
|
||||||
|
|
||||||
|
builder.Services.AddMarkdownPipeline();
|
||||||
builder.Services.ConfigureOptions<OliverBoothConfigureOptions>();
|
builder.Services.ConfigureOptions<OliverBoothConfigureOptions>();
|
||||||
builder.Services.AddSingleton<ITemplateService, TemplateService>();
|
builder.Services.AddSingleton<ITemplateService, TemplateService>();
|
||||||
|
|
||||||
builder.Services.AddSingleton(provider => new MarkdownPipelineBuilder()
|
|
||||||
.Use<TimestampExtension>()
|
|
||||||
.Use(new TemplateExtension(provider.GetRequiredService<ITemplateService>()))
|
|
||||||
.UseAdvancedExtensions()
|
|
||||||
.UseBootstrap()
|
|
||||||
.UseEmojiAndSmiley()
|
|
||||||
.UseSmartyPants()
|
|
||||||
.Build());
|
|
||||||
|
|
||||||
builder.Services.AddDbContextFactory<WebContext>();
|
builder.Services.AddDbContextFactory<WebContext>();
|
||||||
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
|
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
Loading…
Reference in New Issue