feat: inject custom markdown pipeline
This commit is contained in:
parent
d69ef231eb
commit
6524a4f618
@ -1,3 +1,4 @@
|
||||
using Markdig;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -9,10 +10,12 @@ namespace OliverBooth.Pages.Blog;
|
||||
public class Article : PageModel
|
||||
{
|
||||
private readonly IDbContextFactory<BlogContext> _dbContextFactory;
|
||||
private readonly MarkdownPipeline _markdownPipeline;
|
||||
|
||||
public Article(IDbContextFactory<BlogContext> dbContextFactory)
|
||||
public Article(IDbContextFactory<BlogContext> dbContextFactory, MarkdownPipeline markdownPipeline)
|
||||
{
|
||||
_dbContextFactory = dbContextFactory;
|
||||
_markdownPipeline = markdownPipeline;
|
||||
}
|
||||
|
||||
public Author Author { get; private set; }
|
||||
@ -28,7 +31,7 @@ public class Article : PageModel
|
||||
content = content.Replace("\n\n", "\n");
|
||||
}
|
||||
|
||||
return Markdig.Markdown.ToHtml(content.Trim());
|
||||
return Markdown.ToHtml(content.Trim(), _markdownPipeline);
|
||||
}
|
||||
|
||||
public IActionResult OnGet(int year, int month, int day, string slug)
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Markdig;
|
||||
using NLog.Extensions.Logging;
|
||||
using OliverBooth.Data;
|
||||
using OliverBooth.Services;
|
||||
@ -9,6 +10,20 @@ builder.Configuration.AddTomlFile("data/config.toml", true, true);
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddNLog();
|
||||
builder.Services.AddHostedSingleton<LoggingService>();
|
||||
builder.Services.AddSingleton(new MarkdownPipelineBuilder()
|
||||
.UseAbbreviations()
|
||||
.UseAdvancedExtensions()
|
||||
.UseBootstrap()
|
||||
.UseCitations()
|
||||
.UseDiagrams()
|
||||
.UseFigures()
|
||||
.UseFooters()
|
||||
.UseFootnotes()
|
||||
.UseGlobalization()
|
||||
.UseMathematics()
|
||||
.UseAutoIdentifiers()
|
||||
.UseAutoLinks()
|
||||
.Build());
|
||||
|
||||
builder.Services.AddDbContextFactory<BlogContext>();
|
||||
builder.Services.AddDbContextFactory<WebContext>();
|
||||
|
Loading…
Reference in New Issue
Block a user