diff --git a/src/Moonglade.Configuration/ContentSettings.cs b/src/Moonglade.Configuration/ContentSettings.cs index ebc5c4228..0e42d8f14 100644 --- a/src/Moonglade.Configuration/ContentSettings.cs +++ b/src/Moonglade.Configuration/ContentSettings.cs @@ -7,6 +7,9 @@ public class ContentSettings : IBlogSettings { [Display(Name = "Comment provider")] public CommentProvider CommentProvider { get; set; } + + [Display(Name = "Comments display order")] + public CommentOrder CommentOrder { get; set; } [Display(Name = "Post title alignment")] public PostTitleAlignment PostTitleAlignment { get; set; } = PostTitleAlignment.Left; @@ -91,6 +94,12 @@ public enum CommentProvider ThirdParty = 1 } +public enum CommentOrder +{ + OldToNew = 0, + NewToOld = 1 +} + public enum PostTitleAlignment { Left = 0, diff --git a/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml b/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml index 545c63b82..7924061f9 100644 --- a/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml +++ b/src/Moonglade.Web/Pages/Components/CommentList/Default.cshtml @@ -20,8 +20,13 @@ @if (null != Model && Model.Any()) { + var orderedList = + BlogConfig.ContentSettings.CommentOrder == CommentOrder.NewToOld ? + Model.OrderByDescending(m => m.CreateTimeUtc) : + Model.OrderBy(m => m.CreateTimeUtc); +
- @foreach (var item in Model.OrderBy(m => m.CreateTimeUtc)) + @foreach (var item in orderedList) {
@if (BlogConfig.ContentSettings.EnableGravatar && !string.IsNullOrWhiteSpace(item.Email)) @@ -56,9 +61,10 @@ @SharedLocalizer["Author"] - @SharedLocalizer["Replied at"] + + @SharedLocalizer["Replied at"] - +

@Html.Raw(ContentProcessor.MarkdownToContent(reply.ReplyContent, ContentProcessor.MarkdownConvertType.Html)) diff --git a/src/Moonglade.Web/Pages/Settings/Content.cshtml b/src/Moonglade.Web/Pages/Settings/Content.cshtml index 7e90d4ba4..104a7d9e3 100644 --- a/src/Moonglade.Web/Pages/Settings/Content.cshtml +++ b/src/Moonglade.Web/Pages/Settings/Content.cshtml @@ -55,24 +55,43 @@

@Html.RadioButtonFor(model => settings.CommentProvider, CommentProvider.BuiltIn, new - { - id = CommentProvider.BuiltIn.ToString(), - @class = "form-check-input comment-provider-checkbox", - onchange = "window.toggleCommentSettingsUI()" - }) + { + id = CommentProvider.BuiltIn.ToString(), + @class = "form-check-input comment-provider-checkbox", + onchange = "window.toggleCommentSettingsUI()" + })
@Html.RadioButtonFor(model => settings.CommentProvider, CommentProvider.ThirdParty, new - { - id = CommentProvider.ThirdParty.ToString(), - @class = "form-check-input comment-provider-checkbox", - onchange = "window.toggleCommentSettingsUI()" - }) + { + id = CommentProvider.ThirdParty.ToString(), + @class = "form-check-input comment-provider-checkbox", + onchange = "window.toggleCommentSettingsUI()" + })
+ +
+
+ +
+
+ +
+
+
+ @Html.RadioButtonFor(model => settings.CommentOrder, CommentOrder.OldToNew, new { id = CommentOrder.OldToNew.ToString(), @class = "form-check-input" }) + +
+
+ @Html.RadioButtonFor(model => settings.CommentOrder, CommentOrder.NewToOld, new { id = CommentOrder.NewToOld.ToString(), @class = "form-check-input" }) + +
+
+