diff --git a/src/Moonglade.Configuration/SocialLink.cs b/src/Moonglade.Configuration/SocialLink.cs new file mode 100644 index 000000000..4269825cc --- /dev/null +++ b/src/Moonglade.Configuration/SocialLink.cs @@ -0,0 +1,10 @@ +namespace Moonglade.Configuration; + +public class SocialLink +{ + public string Name { get; set; } + + public string Icon { get; set; } + + public string Url { get; set; } +} \ No newline at end of file diff --git a/src/Moonglade.Core/GetAllSocialLinksQuery.cs b/src/Moonglade.Core/GetAllSocialLinksQuery.cs new file mode 100644 index 000000000..77cdd0fb2 --- /dev/null +++ b/src/Moonglade.Core/GetAllSocialLinksQuery.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Configuration; +using Moonglade.Configuration; + +namespace Moonglade.Core; + +public record GetAllSocialLinksQuery : IRequest>; + +public class GetAllSocialLinksQueryHandler(IConfiguration configuration) : IRequestHandler> +{ + public Task> Handle(GetAllSocialLinksQuery request, CancellationToken ct) + { + var section = configuration.GetSection("Experimental:SocialLinks"); + + if (!section.Exists()) + { + return Task.FromResult(new List()); + } + + var links = section.Get>(); + return Task.FromResult(links ?? new List()); + } +} \ No newline at end of file diff --git a/src/Moonglade.Web/Pages/Components/SocialLink/Default.cshtml b/src/Moonglade.Web/Pages/Components/SocialLink/Default.cshtml new file mode 100644 index 000000000..2ab2d3d27 --- /dev/null +++ b/src/Moonglade.Web/Pages/Components/SocialLink/Default.cshtml @@ -0,0 +1,19 @@ +@using Moonglade.Utils +@model List + +@if (Model.Any()) +{ +
+
@SharedLocalizer["Social Links"]
+ +
+ @foreach (var item in Model.OrderBy(c => c.Name)) + { + + + @item.Name + + } +
+
+} \ No newline at end of file diff --git a/src/Moonglade.Web/Pages/Shared/_Aside.cshtml b/src/Moonglade.Web/Pages/Shared/_Aside.cshtml index 6a47ad07d..e73ed8ebb 100644 --- a/src/Moonglade.Web/Pages/Shared/_Aside.cshtml +++ b/src/Moonglade.Web/Pages/Shared/_Aside.cshtml @@ -40,6 +40,13 @@ } + @if (Configuration.GetSection("Experimental:SocialLinks").Exists()) + { + + } + @if (BlogConfig.GeneralSettings.WidgetsFriendLink) {