File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
MoonPress.BlazorDesktop/Components/Pages/Categories Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ @page " /category/{CategoryName}"
2
+
3
+ <h3 >Category: @CategoryName </h3 >
4
+
5
+ @if (! Items .Any ())
6
+ {
7
+ <p >No posts found in this category .</p >
8
+ }
9
+ else
10
+ {
11
+ <ul >
12
+ @foreach ( var item in Items )
13
+ {
14
+ <li class =" mb-3" >
15
+ <strong >
16
+ <a href =" /content-item/edit/@item.Id" >@item.Title </a >
17
+ </strong >
18
+ <div >
19
+ @item.Summary
20
+ </div >
21
+ <small >Published @item.DatePublished.ToString( " yyyy-MM-dd" )</small >
22
+ </li >
23
+ }
24
+ </ul >
25
+ }
Original file line number Diff line number Diff line change
1
+ using Microsoft . AspNetCore . Components ;
2
+ using MoonPress . Core . Content ;
3
+ using MoonPress . Core . Models ;
4
+
5
+ namespace MoonPress . BlazorDesktop . Components . Pages . Categories ;
6
+
7
+ public partial class CategoryDetail : ComponentBase
8
+ {
9
+ [ Parameter ]
10
+ public string CategoryName { get ; set ; } = string . Empty ;
11
+
12
+ private List < ContentItem > Items = new ( ) ;
13
+
14
+ protected override void OnParametersSet ( )
15
+ {
16
+ var all = ContentItemFetcher . GetItemsByCategory ( ) ;
17
+ if ( all . TryGetValue ( CategoryName , out var items ) )
18
+ {
19
+ Items = items
20
+ . OrderByDescending ( i => i . DatePublished )
21
+ . ToList ( ) ;
22
+ }
23
+ else
24
+ {
25
+ Items = new List < ContentItem > ( ) ;
26
+ }
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments