diff --git a/YaeBlog.Core/Models/BlogEssay.cs b/YaeBlog.Core/Models/BlogEssay.cs index 5927d64..5e41f02 100644 --- a/YaeBlog.Core/Models/BlogEssay.cs +++ b/YaeBlog.Core/Models/BlogEssay.cs @@ -1,6 +1,6 @@ namespace YaeBlog.Core.Models; -public class BlogEssay +public class BlogEssay : IComparable { public required string Title { get; init; } @@ -32,6 +32,16 @@ public class BlogEssay return essay; } + public int CompareTo(BlogEssay? other) + { + if (other is null) + { + return 1; + } + + return PublishTime.CompareTo(other.PublishTime); + } + public override string ToString() { return $"{Title}-{PublishTime}"; diff --git a/YaeBlog.Core/Services/EssayContentService.cs b/YaeBlog.Core/Services/EssayContentService.cs index 5ae56b5..b6e3584 100644 --- a/YaeBlog.Core/Services/EssayContentService.cs +++ b/YaeBlog.Core/Services/EssayContentService.cs @@ -34,6 +34,11 @@ public class EssayContentService } } } + + foreach (KeyValuePair> pair in _tags) + { + pair.Value.Sort(); + } } public IEnumerable> Tags => from item in _tags diff --git a/YaeBlog.Theme.FluentUI/Pages/Archives.razor.css b/YaeBlog.Theme.FluentUI/Pages/Archives.razor.css index 8746f42..3b6a576 100644 --- a/YaeBlog.Theme.FluentUI/Pages/Archives.razor.css +++ b/YaeBlog.Theme.FluentUI/Pages/Archives.razor.css @@ -1,6 +1,6 @@ .archive-background { position: relative; - height: 80%; + height: 60%; overflow: hidden; background-repeat: no-repeat; background-size: cover; diff --git a/YaeBlog.Theme.FluentUI/Pages/Tags.razor b/YaeBlog.Theme.FluentUI/Pages/Tags.razor new file mode 100644 index 0000000..05a8ca4 --- /dev/null +++ b/YaeBlog.Theme.FluentUI/Pages/Tags.razor @@ -0,0 +1,92 @@ +@page "/tags" +@using YaeBlog.Core.Models +@using YaeBlog.Core.Services + +@inject BlogOptions BlogOptionsInstance +@inject EssayContentService EssayContentInstance + +
+
+
+ + + @(TagName ?? "标 签") + + +
+
+ +
+ +
+ +
+ @if (TagName is null) + { + + @foreach (KeyValuePair pair in EssayContentInstance.Tags) + { + + } + + } + else + { + + 共计@(EssayContentInstance.GetTag(TagName).Count())篇文章 + + + @foreach (BlogEssay essay in EssayContentInstance.GetTag(TagName)) + { + + } + } +
+
+
+ + +
+ +@code { + [SupplyParameterFromQuery] + private string? TagName { get; set; } + + private static string[] s_colors = + [ + "#337ab7", + "#bbe", + "#4e87c2", + "#a0aee3", + "#6994cd", + "#85a1d8" + ]; + + private static string RandomColor() + { + return Random.Shared.GetItems(s_colors, 1)[0]; + } + +} diff --git a/YaeBlog.Theme.FluentUI/Pages/Tags.razor.css b/YaeBlog.Theme.FluentUI/Pages/Tags.razor.css new file mode 100644 index 0000000..e774855 --- /dev/null +++ b/YaeBlog.Theme.FluentUI/Pages/Tags.razor.css @@ -0,0 +1,27 @@ +.tag-background { + position: relative; + height: 60%; + overflow: hidden; + background-repeat: no-repeat; + background-size: cover; +} + +.tag-title { + top: 43%; + position: absolute; + width: 100%; +} + +.tag-item { + margin: 0.25rem auto; +} + +.tag-essay-item { + padding: 0.5rem 0.5rem 0.5rem 0.5rem; + margin: 0.5rem 0 0.5rem 0; + border-radius: 4px; +} + +.tag-essay-item:hover { + background-color: rgba(169, 169, 169, 0.22); +}