Generate navigation and render page embeds from PocketBase

This commit is contained in:
tleininger committed 2026-09-23 14:54:10 +02:00
1 parent 6b5d9dda55
commit 3fd3796d73
26 files changed
+544 -114

No files matched your search

@@ -0,0 +1,37 @@
using System.Globalization;
using Elternbeirat.Contracts;
using Elternbeirat.PocketBase;
using Microsoft.AspNetCore.Components;
namespace Elternbeirat.Web.Features.Embeds;
public partial class PostsEmbed
{
private static readonly CultureInfo German = CultureInfo.GetCultureInfo("de-DE");
[LoggerMessage(Level = LogLevel.Warning, Message = "Could not load posts for an embed from PocketBase.")]
private static partial void LogLoadFailed(ILogger logger, Exception exception);
[Inject]
private PocketBaseClient PocketBase { get; set; } = default!;
[Inject]
private ILogger<PostsEmbed> Logger { get; set; } = default!;
private IReadOnlyList<Post> _latest = [];
protected override async Task OnInitializedAsync()
{
try
{
// Teaser: the three most recent posts, with a link to the full list.
var posts = await PocketBase.GetPostsAsync();
_latest = [.. posts.Take(3)];
}
catch (HttpRequestException ex)
{
// Source unreachable -> show no teaser instead of a 500.
LogLoadFailed(Logger, ex);
}
}
}