Files
YaeBlog/YaeBlog/Extensions/WebApplicationExtensions.cs
jackfiled 3aae468e65
All checks were successful
Build blog docker image / Build-Blog-Image (push) Successful in 1m15s
feat: 从Bootstrap迁移到Tailwind css (#9)
Reviewed-on: #9
2025-01-24 16:46:56 +08:00

32 lines
1.2 KiB
C#

using YaeBlog.Abstraction;
using YaeBlog.Processors;
using YaeBlog.Services;
namespace YaeBlog.Extensions;
public static class WebApplicationExtensions
{
public static void UseYaeBlog(this WebApplication application)
{
application.UsePostRenderProcessor<ImagePostRenderProcessor>();
application.UsePostRenderProcessor<HeadlinePostRenderProcessor>();
application.UsePostRenderProcessor<EssayStylesPostRenderProcessor>();
}
private static void UsePreRenderProcessor<T>(this WebApplication application) where T : IPreRenderProcessor
{
RendererService rendererService = application.Services.GetRequiredService<RendererService>();
T preRenderProcessor = application.Services.GetRequiredService<T>();
rendererService.AddPreRenderProcessor(preRenderProcessor);
}
private static void UsePostRenderProcessor<T>(this WebApplication application) where T : IPostRenderProcessor
{
RendererService rendererService = application.Services.GetRequiredService<RendererService>();
T postRenderProcessor = application.Services.GetRequiredService<T>();
rendererService.AddPostRenderProcessor(postRenderProcessor);
}
}