YaeBlog/YaeBlog.Core/Extensions/ServiceCollectionExtensions.cs
jackfiled 9111affeec
All checks were successful
Build blog docker image / Build-Blog-Image (push) Successful in 1m34s
feat: 添加内容热重载指令 (#4)
Reviewed-on: #4
2024-08-23 20:24:32 +08:00

35 lines
1.1 KiB
C#

using Markdig;
using Microsoft.Extensions.DependencyInjection;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace YaeBlog.Core.Extensions;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddMarkdig(this IServiceCollection collection)
{
MarkdownPipelineBuilder builder = new();
builder.UseAdvancedExtensions();
collection.AddSingleton<MarkdownPipeline>(_ => builder.Build());
return collection;
}
public static IServiceCollection AddYamlParser(this IServiceCollection collection)
{
DeserializerBuilder deserializerBuilder = new();
deserializerBuilder.WithNamingConvention(CamelCaseNamingConvention.Instance);
deserializerBuilder.IgnoreUnmatchedProperties();
collection.AddSingleton(deserializerBuilder.Build());
SerializerBuilder serializerBuilder = new();
serializerBuilder.WithNamingConvention(CamelCaseNamingConvention.Instance);
collection.AddSingleton(serializerBuilder.Build());
return collection;
}
}