YaeBlog/YaeBlog.Theme.FluentUI/Pages/Essay.razor
2024-01-23 17:55:34 +08:00

58 lines
1.4 KiB
Plaintext

@page "/essays/{Filename}"
@using YaeBlog.Core.Models
@using YaeBlog.Core.Services
@inject BlogOptions BlogOptionsInstance
@inject EssayContentService EssayContent
@inject NavigationManager NavigationInstance
<div style="height: 100%">
<div class="essay-background" style="background-image: url('@(BlogOptionsInstance.EssayImage)')">
<div class="essay-title">
<FluentLabel Typo="@Typography.H1" Style="color: white">
@(_essay!.Title)
</FluentLabel>
</div>
</div>
<div style="height: 2rem"></div>
<div style="margin: 0 8% 0 8%">
<FluentGrid>
<FluentGridItem xs="12" sm="12" md="8" lg="8">
<FluentCard>
<div class="essay-content">
@((MarkupString)_essay!.HtmlContent)
</div>
</FluentCard>
</FluentGridItem>
<FluentGridItem xs="12" sm="12" md="4" lg="4">
</FluentGridItem>
</FluentGrid>
</div>
</div>
@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");
}
}
}