diff --git a/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs b/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs index 17bc010..6f2d378 100644 --- a/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs +++ b/YaeBlog.Theme.FluentUI/BlogApplicationBuilderExtensions.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using Microsoft.FluentUI.AspNetCore.Components; using YaeBlog.Core.Builder; using YaeBlog.Core.Extensions; @@ -15,6 +16,7 @@ public static class BlogApplicationBuilderExtensions private static void ConfigureWebApplicationBuilder(WebApplicationBuilder builder) { builder.Services.AddRazorComponents(); + builder.Services.AddFluentUIComponents(); } private static void ConfigureWebApplication(WebApplication application) diff --git a/YaeBlog.Theme.FluentUI/Pages/Home.razor b/YaeBlog.Theme.FluentUI/Pages/Home.razor index db1bb00..70998c9 100644 --- a/YaeBlog.Theme.FluentUI/Pages/Home.razor +++ b/YaeBlog.Theme.FluentUI/Pages/Home.razor @@ -1,7 +1,10 @@ @page "/" @using YaeBlog.Core.Models +@using YaeBlog.Core.Services @inject BlogOptions BlogOptionsInstance +@inject EssayContentService EssayContentInstance +@inject NavigationManager NavigationManagerInstance
-
+
-
- -
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
- asdfasdfsadf -
-
+
+ + +
+ @foreach (KeyValuePair essay in _essays) + { + +
+ + + @essay.Value.Title + + + + + + + @(essay.Value.PublishTime.ToString("yyyy-MM-dd HH:mm:ss")) + + @if (essay.Value.Tags.Count != 0) + { + + @foreach (string tag in essay.Value.Tags) + { + + @tag + + } + } + +
+
+ } + + +
+
+ + + +
@@ -82,5 +125,39 @@ @code { + [SupplyParameterFromQuery] private int? Page { get; set; } + + private readonly List> _essays = []; + private int _pageCount; + + protected override void OnInitialized() + { + Page ??= 1; + + IEnumerable[]> chunks = + EssayContentInstance.Essays + .OrderByDescending(pair => pair.Value.PublishTime) + .Chunk(10); + + var count = 1; + var flag = false; + foreach (KeyValuePair[] chunk in chunks) + { + if (Page == count) + { + flag = true; + _essays.AddRange(chunk); + } + + count += 1; + } + + _pageCount = count - 1; + + if (flag is false) + { + NavigationManagerInstance.NavigateTo("NotFount"); + } + } } diff --git a/YaeBlog.Theme.FluentUI/Pages/Home.razor.css b/YaeBlog.Theme.FluentUI/Pages/Home.razor.css index e3804c8..51764bb 100644 --- a/YaeBlog.Theme.FluentUI/Pages/Home.razor.css +++ b/YaeBlog.Theme.FluentUI/Pages/Home.razor.css @@ -54,3 +54,37 @@ opacity: 0.4; } } + +.essay-description { + vertical-align: middle; +} + +.pagination { + font-size: 2em; +} + +.pagination-item { + margin: auto 0 auto 0; +} + +.chevron-left { + font-size: 1.2rem; + font-family: "Font Awesome 6 Free", sans-serif; + font-style: normal; + font-weight: 900; +} + +.chevron-left::before { + content: "\f053"; +} + +.chevron-right { + font-size: 1.2rem; + font-family: "Font Awesome 6 Free", sans-serif; + font-style: normal; + font-weight: 900; +} + +.chevron-right::before { + content: "\f054"; +} diff --git a/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj b/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj index 545c700..562c42d 100644 --- a/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj +++ b/YaeBlog.Theme.FluentUI/YaeBlog.Theme.FluentUI.csproj @@ -14,6 +14,7 @@ +