From ee9dc574fc7c31c61faa3e355992ab110481dd04 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 21 Jul 2024 21:17:11 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=AD=98=E6=A1=A3=E9=A1=B5=E5=92=8C?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YaeBlog.Core/Services/EssayContentService.cs | 1 + YaeBlog/Components/BlogInformationCard.razor | 42 +++++++++++- YaeBlog/Components/EssayCard.razor | 39 +++++++++++ YaeBlog/Components/EssayCard.razor.css | 3 + YaeBlog/Layout/BlogLayout.razor | 8 +-- YaeBlog/Pages/About.razor | 9 +++ YaeBlog/Pages/About.razor.css | 0 YaeBlog/Pages/Archives.razor | 72 ++++++++++++++++++++ YaeBlog/Pages/Archives.razor.css | 0 YaeBlog/Pages/BlogIndex.razor | 40 ++--------- YaeBlog/Pages/Essays.razor | 29 +++++++- YaeBlog/Pages/Tags.razor | 67 ++++++++++++++++++ YaeBlog/Pages/Tags.razor.css | 6 ++ 13 files changed, 273 insertions(+), 43 deletions(-) create mode 100644 YaeBlog/Components/EssayCard.razor create mode 100644 YaeBlog/Components/EssayCard.razor.css create mode 100644 YaeBlog/Pages/About.razor create mode 100644 YaeBlog/Pages/About.razor.css create mode 100644 YaeBlog/Pages/Archives.razor create mode 100644 YaeBlog/Pages/Archives.razor.css create mode 100644 YaeBlog/Pages/Tags.razor create mode 100644 YaeBlog/Pages/Tags.razor.css diff --git a/YaeBlog.Core/Services/EssayContentService.cs b/YaeBlog.Core/Services/EssayContentService.cs index 2fcef74..2ddc98c 100644 --- a/YaeBlog.Core/Services/EssayContentService.cs +++ b/YaeBlog.Core/Services/EssayContentService.cs @@ -40,6 +40,7 @@ public class EssayContentService } public IEnumerable> Tags => from item in _tags + orderby item.Value.Count descending select KeyValuePair.Create(item.Key, item.Value.Count); public int TagCount => _tags.Count; diff --git a/YaeBlog/Components/BlogInformationCard.razor b/YaeBlog/Components/BlogInformationCard.razor index 98903e3..ed3cc6b 100644 --- a/YaeBlog/Components/BlogInformationCard.razor +++ b/YaeBlog/Components/BlogInformationCard.razor @@ -1,4 +1,42 @@ -
-

“奇奇怪怪东西的聚合地”

+@using YaeBlog.Core.Services + +@inject EssayContentService EssayContentInstance + +
+
+
+ Ricardo's avatar +
+
+ +
+
+ “奇奇怪怪东西的聚合地” +
+
+ + + +
diff --git a/YaeBlog/Components/EssayCard.razor b/YaeBlog/Components/EssayCard.razor new file mode 100644 index 0000000..6c4c34e --- /dev/null +++ b/YaeBlog/Components/EssayCard.razor @@ -0,0 +1,39 @@ +@using YaeBlog.Core.Models + +
+ + +
+
+ @(Essay.PublishTime.ToString("yyyy-MM-dd")) +
+ + @foreach (string key in Essay.Tags) + { + + } +
+ +
+
+ @(Essay.Description) +
+
+ +
+
+ +
+
+
+ +@code { + [Parameter] + public required BlogEssay Essay { get; set; } +} diff --git a/YaeBlog/Components/EssayCard.razor.css b/YaeBlog/Components/EssayCard.razor.css new file mode 100644 index 0000000..4dd8b69 --- /dev/null +++ b/YaeBlog/Components/EssayCard.razor.css @@ -0,0 +1,3 @@ +.essay-title a { + color: var(--bs-body-color); +} diff --git a/YaeBlog/Layout/BlogLayout.razor b/YaeBlog/Layout/BlogLayout.razor index 97e0e9c..a997991 100644 --- a/YaeBlog/Layout/BlogLayout.razor +++ b/YaeBlog/Layout/BlogLayout.razor @@ -11,28 +11,28 @@
- +
首页
- +
归档
- +
标签
- +
关于
diff --git a/YaeBlog/Pages/About.razor b/YaeBlog/Pages/About.razor new file mode 100644 index 0000000..6b31744 --- /dev/null +++ b/YaeBlog/Pages/About.razor @@ -0,0 +1,9 @@ +@page "/blog/about" + +
+ +
+ +@code { + +} diff --git a/YaeBlog/Pages/About.razor.css b/YaeBlog/Pages/About.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/YaeBlog/Pages/Archives.razor b/YaeBlog/Pages/Archives.razor new file mode 100644 index 0000000..fee7717 --- /dev/null +++ b/YaeBlog/Pages/Archives.razor @@ -0,0 +1,72 @@ +@page "/blog/archives" +@using YaeBlog.Core.Models +@using YaeBlog.Core.Services + +@inject EssayContentService EssayContentInstance + +
+ +@code { + private readonly List>> _essays = []; + + protected override void OnInitialized() + { + base.OnInitialized(); + + _essays.AddRange(from essay in EssayContentInstance.Essays + orderby essay.Value.PublishTime descending + group essay by new DateTime(essay.Value.PublishTime.Year, 1, 1)); + } + +} diff --git a/YaeBlog/Pages/Archives.razor.css b/YaeBlog/Pages/Archives.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/YaeBlog/Pages/BlogIndex.razor b/YaeBlog/Pages/BlogIndex.razor index a3f9467..377d43f 100644 --- a/YaeBlog/Pages/BlogIndex.razor +++ b/YaeBlog/Pages/BlogIndex.razor @@ -4,45 +4,13 @@ @inject EssayContentService EssayContentInstance @inject NavigationManager NavigationInstance -@inject ILogger Logger
@foreach (KeyValuePair pair in _essays) { -
- - -
-
- @(pair.Value.PublishTime.ToString("yyyy-MM-dd")) -
- - @foreach (string key in pair.Value.Tags) - { - - } -
- -
-
- @(pair.Value.Description) -
-
- -
-
- -
-
-
+ }
@@ -60,7 +28,7 @@ @if (_page == 1) {
- 1 + 1
2 @@ -78,7 +46,7 @@ @(_pageCount - 1)
- @(_pageCount) + @(_pageCount)
} else @@ -87,7 +55,7 @@ @(_page - 1)
- @(_page) + @(_page)
@(_page + 1) diff --git a/YaeBlog/Pages/Essays.razor b/YaeBlog/Pages/Essays.razor index abface1..24fb49e 100644 --- a/YaeBlog/Pages/Essays.razor +++ b/YaeBlog/Pages/Essays.razor @@ -5,8 +5,35 @@ @inject NavigationManager NavigationInstance @inject EssayContentService EssayContentInstance -
+ + @(_essay!.Title) + +
+
+
+

@(_essay!.Title)

+
+
+ +
+
+ @(_essay!.PublishTime.ToString("yyyy-MM-dd")) +
+ + @foreach (string tag in _essay!.Tags) + { +
+ # @(tag) +
+ } +
+ +
+
+ @((MarkupString)_essay!.HtmlContent) +
+
@code { diff --git a/YaeBlog/Pages/Tags.razor b/YaeBlog/Pages/Tags.razor new file mode 100644 index 0000000..6319668 --- /dev/null +++ b/YaeBlog/Pages/Tags.razor @@ -0,0 +1,67 @@ +@page "/blog/tags/" +@using YaeBlog.Core.Models +@using YaeBlog.Core.Services + +@inject EssayContentService EssayContentInstance + +
+
+
+ @if (TagName is null) + { +

标签

+ } + else + { +

@(TagName)

+ } +
+
+ +
+
+ 在野外游荡的指针,走向未知的方向。 +
+
+ + @if (TagName is null) + { +
+ +
+ } + else + { +
+ @foreach (BlogEssay essay in EssayContentInstance.GetTag(TagName).OrderByDescending(e => e.PublishTime)) + { + + } +
+ } +
+ +@code { + [SupplyParameterFromQuery] public string? TagName { get; set; } + + +} diff --git a/YaeBlog/Pages/Tags.razor.css b/YaeBlog/Pages/Tags.razor.css new file mode 100644 index 0000000..49d2e8f --- /dev/null +++ b/YaeBlog/Pages/Tags.razor.css @@ -0,0 +1,6 @@ +.tag-count { + background: var(--bs-secondary-bg); + border-radius: 5px; + padding: 0 6px; +} +