Write proper FAQ page intro; drop dead faqs-embed from tests

This commit is contained in:
tleininger committed 2026-09-30 15:13:19 +02:00
1 parent e38ebf078d
commit cb345975cb
5 files changed
+47 -22

No files matched your search

+13 -2
View File
@@ -1,8 +1,19 @@
@page "/faqs"
<PageTitle>Häufige Fragen</PageTitle>
@{
// Heading and intro come from the "faqs" page record; fall back to a sensible
// default only if that record is missing, so the page still renders.
var title = _page?.Title ?? "FAQs";
}
<h1>Häufige Fragen</h1>
<PageTitle>@title</PageTitle>
<h1>@title</h1>
@if (_page is not null && !string.IsNullOrWhiteSpace(_page.Body))
{
<article>@Body</article>
}
@if (_unavailable)
{
@@ -23,6 +23,11 @@ public partial class FaqList
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
// The "faqs" page record supplies the heading and intro text, so an editor
// owns them in PocketBase rather than them being hard-coded here. Null until
// loaded, or when no such page exists.
private Page? _page;
private IReadOnlyList<FaqTopic> _topics = [];
// Set when the content source could not be reached or read. The markup then
@@ -30,11 +35,19 @@ public partial class FaqList
// the 503 this sets on the response.
private bool _unavailable;
// The page body rendered from Markdown to HTML, ready to emit as a
// MarkupString in the markup.
private MarkupString Body => (MarkupString)Markdown.ToHtml(_page?.Body);
protected override async Task OnInitializedAsync()
{
try
{
_topics = await PocketBase.GetFaqTopicsAsync(HttpContext?.RequestAborted ?? CancellationToken.None);
var token = HttpContext?.RequestAborted ?? CancellationToken.None;
var pages = await PocketBase.GetPagesAsync(token);
_page = pages.FirstOrDefault(
page => string.Equals(page.Slug, "faqs", StringComparison.OrdinalIgnoreCase));
_topics = await PocketBase.GetFaqTopicsAsync(token);
}
catch (PocketBaseUnavailableException exception)
{