using Elternbeirat.Contracts; namespace Elternbeirat.Web.Features.Layout; /// /// Builds the header and footer navigation from the public pages. Every page /// carries a required ("header" or "footer") and an /// ; this splits them into the two menus, each ordered. /// public static class NavBuilder { /// Header links, ordered, built from pages with location "header". public static IReadOnlyList Header(IReadOnlyList pages) => Build(pages, "header"); /// Footer links, ordered, built from pages with location "footer". public static IReadOnlyList Footer(IReadOnlyList pages) => Build(pages, "footer"); private static List Build( IReadOnlyList pages, string location) => [.. pages .Where(page => string.Equals(page.Location, location, StringComparison.Ordinal)) .OrderBy(page => page.Order) .Select(page => new NavLinkItem(HrefFor(page.Slug), page.Title))]; // The home page owns "/" (served by the Home component); every other slug is // reached at "/{slug}", where either a literal route or the catch-all content // page renders it. private static string HrefFor(string slug) => Page.IsHomeSlug(slug) ? "/" : $"/{slug}"; }