@page "/essays/{Filename}"
@using YaeBlog.Core.Models
@using YaeBlog.Core.Services
@inject BlogOptions BlogOptionsInstance
@inject EssayContentService EssayContent
@inject NavigationManager NavigationInstance
@(_essay!.Title)
@(_essay!.Title)
@(_essay!.PublishTime.ToString("yyyy年MM月dd日"))
@(_essay!.WordCount)字
@((MarkupString)_essay!.HtmlContent)
@code {
[Parameter] public string? Filename { get; set; }
private BlogEssay? _essay;
protected override void OnInitialized()
{
if (string.IsNullOrEmpty(Filename))
{
NavigationInstance.NavigateTo("NotFound");
return;
}
if (!EssayContent.TryGet(Filename, out _essay))
{
NavigationInstance.NavigateTo("NotFound");
}
}
}