2024-04-10 01:28:38 -05:00
|
|
|
@namespace Blog.Components
|
|
|
|
|
@inject IPostService postService
|
|
|
|
|
@inject IJSRuntime JS
|
|
|
|
|
|
2024-04-11 00:58:22 -05:00
|
|
|
|
|
|
|
|
@if (Posts is null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (Posts.Count == 0)
|
2024-04-10 01:28:38 -05:00
|
|
|
{
|
|
|
|
|
<div class="container">
|
|
|
|
|
<p>Looks like writers block. Check back later.</p>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<section role="feed" class="container">
|
2024-04-11 00:58:22 -05:00
|
|
|
@foreach (var post in Posts)
|
2024-04-10 01:28:38 -05:00
|
|
|
{
|
|
|
|
|
<a href="/@post.Slug">
|
|
|
|
|
<article>
|
|
|
|
|
<h3 title="@post.Title" >@post.Title</h3>
|
|
|
|
|
<p class="date">@post.PublishedAt.ToString("MMMM d, yyyy")</p>
|
|
|
|
|
<p class="lead">@post.Lead</p>
|
|
|
|
|
</article>
|
|
|
|
|
</a>
|
|
|
|
|
}
|
|
|
|
|
</section>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@code {
|
2024-04-11 00:58:22 -05:00
|
|
|
private List<Post>? Posts;
|
2024-04-10 01:28:38 -05:00
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2024-04-11 00:58:22 -05:00
|
|
|
Posts = await postService.GetPostsAsync();
|
2024-04-10 01:28:38 -05:00
|
|
|
}
|
|
|
|
|
}
|