Files
Elternbeirat/Elternbeirat.Contracts/Page.cs
T

80 lines
2.4 KiB
C#

using System.Text.Json.Serialization;
namespace Elternbeirat.Contracts;
/// <summary>
/// A content page of the site, as stored in PocketBase.
/// </summary>
/// <remarks>
/// Pages also drive the site navigation: <see cref="Location"/> and
/// <see cref="Order"/> decide where and in which order a page appears in the
/// header or footer menu. <see cref="Embed"/> lists dynamic blocks rendered
/// below the page body.
/// </remarks>
public record Page
{
/// <summary>
/// Gets the PocketBase record id.
/// </summary>
[JsonPropertyName("id")]
public string Id { 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 page body as Markdown.
/// </summary>
[JsonPropertyName("body")]
public string Body { get; init; } = "";
/// <summary>
/// Gets the navigation menu the page appears in.
/// </summary>
/// <value>
/// Either <c>"header"</c> or <c>"footer"</c>.
/// </value>
[JsonPropertyName("location")]
public string Location { get; init; } = "";
/// <summary>
/// Gets the sort order within the navigation menu given by <see cref="Location"/>.
/// </summary>
/// <value>
/// The sort key; pages with smaller values appear first.
/// </value>
[JsonPropertyName("order")]
public double Order { get; init; }
/// <summary>
/// Gets the URL slug of the page, e.g. <c>"board"</c> for <c>/board</c>.
/// </summary>
/// <value>
/// A lowercase path segment without umlauts.
/// </value>
[JsonPropertyName("slug")]
public string Slug { get; init; } = "";
/// <summary>
/// Gets the dynamic blocks rendered below the <see cref="Body"/>.
/// </summary>
/// <value>
/// Any of <c>"posts"</c>, <c>"events"</c> and <c>"faqs"</c>, or an empty list
/// for a plain text page.
/// </value>
[JsonPropertyName("embed")]
public IReadOnlyList<string> Embed { get; init; } = [];
/// <summary>
/// Gets a value indicating whether the page is visible to visitors of the site.
/// </summary>
[JsonPropertyName("public")]
public bool Public { get; init; }
}