@page "/archives"
@using YaeBlog.Core.Models
@using YaeBlog.Core.Services
@inject BlogOptions BlogOptionsInstance
@inject EssayContentService EssayContentInstance
共计@(EssayContentInstance.Count)篇文章
@foreach (IGrouping
> group in _essays)
{
@(group.Key.ToString("yyyy年"))
@foreach (KeyValuePair
pair in group)
{
}
}
@code {
private readonly List>> _essays = [];
protected override void OnInitialized()
{
IEnumerable>> essays =
from essay in EssayContentInstance.Essays
orderby essay.Value.PublishTime descending
group essay by new DateTime(essay.Value.PublishTime.Year, 1, 1);
_essays.AddRange(essays);
}
}