-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathYear.cshtml
More file actions
46 lines (41 loc) · 1.66 KB
/
Year.cshtml
File metadata and controls
46 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@page "/posts/year/{year}"
@model YearModel
@inject MarkdownBlog Blog
@implements IRenderStatic<YearModel>
@functions {
public List<YearModel> GetStaticProps(RenderContext ctx) => ctx.Resolve<MarkdownBlog>()
.VisiblePosts.Select(x => x.Date.GetValueOrDefault().Year).Distinct().Map(x => new YearModel { Year = x });
}
@{
ViewData["Title"] = $"{Model.Year} posts";
var allYears = Blog.VisiblePosts.Select(x => x.Date.Value.Year).Distinct().OrderByDescending(x => x);
}
<div class="relative bg-gray-50 dark:bg-gray-900 px-6 pt-16 pb-20 lg:px-8 lg:pt-24 lg:pb-28">
<div class="absolute inset-0">
<div class="h-1/3 bg-white dark:bg-black sm:h-2/3"></div>
</div>
<div class="relative mx-auto max-w-7xl">
@await Html.PartialAsync("BlogTitle", $"All posts published in <b>{Model.Year}</b>")
</div>
<div class="mt-4 relative mb-8 mx-auto max-w-7xl">
<div class="flex flex-wrap justify-center">
@foreach (var year in allYears)
{
if (Model.Year == year)
{
<b class="ml-3 text-sm font-semibold">@year</b>
}
else
{
<a class="ml-3 text-sm text-indigo-700 font-semibold hover:underline" href="@Blog.GetYearLink(year)">@year</a>
}
}
</div>
</div>
<div class="mt-12 relative mx-auto max-w-7xl">
@await Html.PartialAsync("BlogPosts", Blog.GetPosts(year:Model.Year))
<div class="mt-8 text-center">
<a class="text-sm font-semibold hover:underline" href="@Blog.GetPostsLink()">view all posts</a>
</div>
</div>
</div>