Files
Elternbeirat/Elternbeirat.Contracts/Post.cs
T

62 lines
1.9 KiB
C#

using System.Text.Json.Serialization;
namespace Elternbeirat.Contracts;
/// <summary>
/// A news post of the site, as stored in PocketBase.
/// </summary>
/// <remarks>
/// Post lists are ordered by <see cref="Date"/>, newest first.
/// </remarks>
public record Post
{
/// <summary>
/// Gets the PocketBase record id.
/// </summary>
[JsonPropertyName("id")]
public string Id { get; init; } = "";
/// <summary>
/// Gets the publication date as a calendar day.
/// </summary>
/// <remarks>
/// A post's date is a plain day, not a point in time. It is read as the
/// Berlin calendar day: the UTC value is converted to Europe/Berlin and only
/// the day is kept, so the day an editor picked is the day shown -- no
/// time-of-day, no off-by-one at midnight. See <see cref="DateOnlyConverter"/>.
/// </remarks>
[JsonPropertyName("date")]
[JsonConverter(typeof(DateOnlyConverter))]
public DateOnly Date { get; init; }
/// <summary>
/// Gets the heading shown to visitors.
/// </summary>
/// <remarks>
/// Free text; may contain umlauts and spaces. For the URL, see <see cref="Slug"/>.
/// </remarks>
[JsonPropertyName("title")]
public string Title { get; init; } = "";
/// <summary>
/// Gets the post body as Markdown.
/// </summary>
[JsonPropertyName("body")]
public string Body { get; init; } = "";
/// <summary>
/// Gets the URL slug of the post, e.g. <c>"herbstbasar"</c> for <c>/posts/herbstbasar</c>.
/// </summary>
/// <value>
/// A lowercase path segment without umlauts.
/// </value>
[JsonPropertyName("slug")]
public string Slug { get; init; } = "";
/// <summary>
/// Gets a value indicating whether the post is visible to visitors of the site.
/// </summary>
[JsonPropertyName("public")]
public bool Public { get; init; }
}