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,36 @@
using Elternbeirat.PocketBase;
using Elternbeirat.Web.Features.Layout;
using Microsoft.AspNetCore.Components;
namespace Elternbeirat.Web.Components.Layout;
public partial class MainLayout
{
[LoggerMessage(Level = LogLevel.Warning, Message = "Could not load navigation pages from PocketBase.")]
private static partial void LogLoadFailed(ILogger logger, Exception exception);
[Inject]
private PocketBaseClient PocketBase { get; set; } = default!;
[Inject]
private ILogger<MainLayout> Logger { get; set; } = default!;
private IReadOnlyList<NavLinkItem> _header = [];
private IReadOnlyList<NavLinkItem> _footer = [];
protected override async Task OnInitializedAsync()
{
try
{
var pages = await PocketBase.GetPagesAsync();
_header = NavBuilder.Header(pages);
_footer = NavBuilder.Footer(pages);
}
catch (HttpRequestException ex)
{
// Source unreachable -> render the chrome with an empty menu instead of
// a 500. The brand link still leads home.
LogLoadFailed(Logger, ex);
}
}
}