Wave/Wave/Components/ArticleCard.razor

43 lines
1.3 KiB
Plaintext

@using Wave.Data
@using Humanizer
<article class="card card-side card-compact bg-base-200 text-base-content">
<figure class="shrink-0 max-md:!hidden sm:max-w-40">
<ArticleLink Article="Article">
<img src="/api/user/pfp/@Article.Author.Id" alt="" width="800">
</ArticleLink>
</figure>
<div class="card-body">
<ArticleLink Article="Article">
<h2 class="card-title line-clamp-1">@Article.Title</h2>
<small>
@Article.PublishDate.ToString("d")
@if (Article.Status is not ArticleStatus.Published) {
<span class="badge badge-sm badge-warning ml-2">@Article.Status.Humanize()</span>
}
</small>
<p class="@(Article.Categories.Count > 0 ? "line-clamp-2" : "line-clamp-4")">
@Article.BodyPlain[..Math.Min(1000, Article.BodyPlain.Length)]
</p>
</ArticleLink>
@if (Action is not null) {
<div class="card-actions w-full">
@Action(Article)
</div>
} else if (Article.Categories.Count > 0) {
<div class="card-actions flex flex-wrap gap-2">
@foreach (var category in Article.Categories.OrderBy(c => c.Color)) {
<CategoryBadgeComponent Category="category" />
}
</div>
}
</div>
</article>
@code {
[Parameter]
public required Article Article { get; set; }
[Parameter]
public RenderFragment<Article>? Action { get; set; }
}