Files
blog.stevanfreeborn.com/src/Blog/Components/Posts/Feed.razor
T
Stevan Freeborn 14f0d06cf4 post: add post about building the blog (#10)
* post: stub out initial post with outline

* fix: add title attribute to lead in feed and add disc to list styles in posts

* fix: apply style to artcile

* post: work on rough draft

* post: work on rough draft

* post: work on rought draft

* post: work on rought draft

* post: more work on rough draft

* post: finish post

* chore: cleanup usings

* chore: run dotnet format

* docs: testing README

* docs: update README.md
2024-04-18 22:24:12 -05:00

42 lines
883 B
Plaintext

@namespace Blog.Components
@inject IPostService postService
@inject IJSRuntime JS
@if (Posts is null)
{
return;
}
else if (Posts.Count == 0)
{
<div class="container">
<p>Looks like writers block. Check back later.</p>
</div>
}
else
{
<section role="feed" class="container">
@foreach (var post in Posts)
{
<article>
<NavLink href="@GetLink(post)">
<h3 title="@post.Title" >@post.Title</h3>
<p class="date">@post.PublishedAt.ToString("MMMM d, yyyy")</p>
<p class="lead" title="@post.Lead">@post.Lead</p>
</NavLink>
</article>
}
</section>
}
@code
{
private List<Post>? Posts;
private string GetLink(Post post) => $"/{post.Slug}";
protected override async Task OnInitializedAsync()
{
Posts = await postService.GetPostsAsync();
}
}