47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Elternbeirat.Contracts;
|
|
using Elternbeirat.Web.Shared;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Elternbeirat.Web.Features.Posts;
|
|
|
|
/// <summary>
|
|
/// Renders one post as a card linking to the post, with date, title and teaser.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Shared by the posts page and the home-page posts embed, so both show posts the
|
|
/// same way. The teaser comes from the body (<see cref="Markdown.Teaser"/>): posts
|
|
/// have no summary field of their own.
|
|
/// </remarks>
|
|
/// <seealso cref="PostDate"/>
|
|
public partial class PostCard
|
|
{
|
|
/// <summary>
|
|
/// The post to show.
|
|
/// </summary>
|
|
[Parameter]
|
|
[EditorRequired]
|
|
public Post Value { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// <see langword="true"/> for the large card that opens the posts page (the
|
|
/// newest post); <see langword="false"/> for a regular card.
|
|
/// </summary>
|
|
[Parameter]
|
|
public bool Featured { get; set; }
|
|
|
|
/// <summary>
|
|
/// The card's classes; the featured card adds its modifier.
|
|
/// </summary>
|
|
private string CssClass => Featured ? "post-card post-card-featured" : "post-card";
|
|
|
|
/// <summary>
|
|
/// The address of the post.
|
|
/// </summary>
|
|
private string Href => $"/posts/{Value.Slug}";
|
|
|
|
/// <summary>
|
|
/// The teaser text; empty if the body has no paragraph text.
|
|
/// </summary>
|
|
private string Teaser => Markdown.Teaser(Value.Body);
|
|
}
|