FAQ: Doku an faq_topics angleichen #38

Closed
opened 2026-10-01 11:06:48 +02:00 by Tom · 0 comments
Owner

docs/redaktion.md (Abschnitt „Häufige Fragen“) beschreibt faqs.topic als freien Text, aus dem die Gruppen entstehen. Schema (pb/pb_migrations/collections_schema.json) und Live-Daten haben aber eine eigene Collection faq_topics (title, slug, intro, order, public) und faqs.topic als Relation. Die Doku ist damit veraltet und führt Redakteure in die Irre.

Aufgaben

  • docs/redaktion.md: FAQ-Abschnitt auf faq_topics + Relation umschreiben (inkl. Tabelle der Collections, embed-Werte prüfen)
Verworfener Entwurf FaqTopicsEmbed (nie committet, nutzte eine nicht vorhandene EmbedCard)
@if (_topics.Count > 0)
{
    <section class="embed embed-faq-topics">
        <h2>Häufige Fragen</h2>
        <ul class="embed-cards">
            @foreach (var topic in _topics)
            {
                <EmbedCard Title="@topic.Title" Href="@TopicHref(topic)" />
            }
        </ul>
    </section>
}
using Elternbeirat.Contracts;
using Elternbeirat.PocketBase;
using Microsoft.AspNetCore.Components;

namespace Elternbeirat.Web.Features.Embeds;

public partial class FaqTopicsEmbed
{
    [LoggerMessage(
        Level = LogLevel.Warning,
        Message = "Could not load FAQ topics for an embed from PocketBase; the block is omitted.")]
    private static partial void LogSourceUnavailable(
        ILogger logger,
        Exception exception);

    [Inject]
    private PocketBaseClient PocketBase { get; set; } = null!;

    [Inject]
    private ILogger<FaqTopicsEmbed> Logger { get; set; } = null!;

    [CascadingParameter]
    private HttpContext? HttpContext { get; set; }

    // The route FaqTopicPage (@page "/faqs/{Slug}") serves. Kept as one named
    // constant so the link the embed builds and the page's own route stay in step.
    private const string TopicRoutePrefix = "/faqs/";

    private IReadOnlyList<FaqTopic> _topics = [];

    /// <summary>The link to a topic's own page, e.g. <c>/faqs/lunch</c>.</summary>
    /// <param name="topic">The topic to link to; its <see cref="FaqTopic.Slug"/> forms the last path segment.</param>
    /// <returns>The relative URL of the topic's page.</returns>
    private static string TopicHref(FaqTopic topic) => TopicRoutePrefix + topic.Slug;

    protected override async Task OnInitializedAsync()
    {
        try
        {
            // GetFaqTopicsAsync returns the topics ordered, so the list can be
            // rendered verbatim. Unlike a teaser, all topics are shown.
            _topics = await PocketBase.GetFaqTopicsAsync(HttpContext?.RequestAborted ?? CancellationToken.None);
        }
        catch (PocketBaseUnavailableException exception)
        {
            // Only part of the page fails: omit the block, keep the page (and its
            // 200) intact. A missing block is degraded, not broken.
            LogSourceUnavailable(Logger, exception);
        }
    }
}

Blockiert den Start von „Design auffrischen“ (#37), damit sich die Arbeiten nicht überschneiden.

Gehört zu #6.

`docs/redaktion.md` (Abschnitt „Häufige Fragen“) beschreibt `faqs.topic` als **freien Text**, aus dem die Gruppen entstehen. Schema (`pb/pb_migrations/collections_schema.json`) und Live-Daten haben aber eine eigene Collection **`faq_topics`** (title, slug, intro, order, public) und `faqs.topic` als **Relation**. Die Doku ist damit veraltet und führt Redakteure in die Irre. ## Aufgaben - [x] `docs/redaktion.md`: FAQ-Abschnitt auf `faq_topics` + Relation umschreiben (inkl. Tabelle der Collections, `embed`-Werte prüfen) <details> <summary>Verworfener Entwurf <code>FaqTopicsEmbed</code> (nie committet, nutzte eine nicht vorhandene <code>EmbedCard</code>)</summary> ```razor @if (_topics.Count > 0) { <section class="embed embed-faq-topics"> <h2>Häufige Fragen</h2> <ul class="embed-cards"> @foreach (var topic in _topics) { <EmbedCard Title="@topic.Title" Href="@TopicHref(topic)" /> } </ul> </section> } ``` ```csharp using Elternbeirat.Contracts; using Elternbeirat.PocketBase; using Microsoft.AspNetCore.Components; namespace Elternbeirat.Web.Features.Embeds; public partial class FaqTopicsEmbed { [LoggerMessage( Level = LogLevel.Warning, Message = "Could not load FAQ topics for an embed from PocketBase; the block is omitted.")] private static partial void LogSourceUnavailable( ILogger logger, Exception exception); [Inject] private PocketBaseClient PocketBase { get; set; } = null!; [Inject] private ILogger<FaqTopicsEmbed> Logger { get; set; } = null!; [CascadingParameter] private HttpContext? HttpContext { get; set; } // The route FaqTopicPage (@page "/faqs/{Slug}") serves. Kept as one named // constant so the link the embed builds and the page's own route stay in step. private const string TopicRoutePrefix = "/faqs/"; private IReadOnlyList<FaqTopic> _topics = []; /// <summary>The link to a topic's own page, e.g. <c>/faqs/lunch</c>.</summary> /// <param name="topic">The topic to link to; its <see cref="FaqTopic.Slug"/> forms the last path segment.</param> /// <returns>The relative URL of the topic's page.</returns> private static string TopicHref(FaqTopic topic) => TopicRoutePrefix + topic.Slug; protected override async Task OnInitializedAsync() { try { // GetFaqTopicsAsync returns the topics ordered, so the list can be // rendered verbatim. Unlike a teaser, all topics are shown. _topics = await PocketBase.GetFaqTopicsAsync(HttpContext?.RequestAborted ?? CancellationToken.None); } catch (PocketBaseUnavailableException exception) { // Only part of the page fails: omit the block, keep the page (and its // 200) intact. A missing block is degraded, not broken. LogSourceUnavailable(Logger, exception); } } } ``` </details> Blockiert den Start von „Design auffrischen“ (#37), damit sich die Arbeiten nicht überschneiden. Gehört zu #6.
Tom added this to the Elternbeirat-Website milestone 2026-10-01 11:06:48 +02:00
Tom changed title from FAQ: Doku an faq_topics angleichen, FaqTopicsEmbed klären to FAQ: Doku an faq_topics angleichen 2026-10-01 11:23:32 +02:00
Tom closed this issue 2026-10-01 11:40:50 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Tom/Elternbeirat#38