Add home hero with intro and buttons from the body, next-event card and page tiles
This commit is contained in:
1 parent
b737f57ef7
commit
e51afeb34b
23 files changed
+1262
-65
No files matched your search
@@ -11,23 +11,45 @@ public static class NavBuilder
|
||||
{
|
||||
/// <summary>Header links, ordered, built from pages with location "header".</summary>
|
||||
public static IReadOnlyList<NavLinkItem> Header(IReadOnlyList<Page> pages) =>
|
||||
Build(pages, "header");
|
||||
ToLinks(PagesAt(pages, "header"));
|
||||
|
||||
/// <summary>Footer links, ordered, built from pages with location "footer".</summary>
|
||||
public static IReadOnlyList<NavLinkItem> Footer(IReadOnlyList<Page> pages) =>
|
||||
Build(pages, "footer");
|
||||
ToLinks(PagesAt(pages, "footer"));
|
||||
|
||||
private static List<NavLinkItem> Build(
|
||||
/// <summary>
|
||||
/// Returns the pages of the header menu themselves, in menu order.
|
||||
/// </summary>
|
||||
/// <param name="pages">All public pages.</param>
|
||||
/// <returns>The pages with location <c>header</c>, ordered by <see cref="Page.Order"/>.</returns>
|
||||
/// <remarks>
|
||||
/// For callers that need more than a link, such as the tiles on the home page,
|
||||
/// which also show part of each page's body. Using the same selection as
|
||||
/// <see cref="Header"/> keeps tiles and menu in step.
|
||||
/// </remarks>
|
||||
public static IReadOnlyList<Page> HeaderPages(IReadOnlyList<Page> pages) =>
|
||||
PagesAt(pages, "header");
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL a page is reached at.
|
||||
/// </summary>
|
||||
/// <param name="slug">The page's slug.</param>
|
||||
/// <returns><c>/</c> for the home page, otherwise <c>/{slug}</c>.</returns>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public static string HrefFor(string slug) =>
|
||||
Page.IsHomeSlug(slug) ? "/" : $"/{slug}";
|
||||
|
||||
private static List<Page> PagesAt(
|
||||
IReadOnlyList<Page> 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))];
|
||||
.OrderBy(page => page.Order)];
|
||||
|
||||
// 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}";
|
||||
private static List<NavLinkItem> ToLinks(IEnumerable<Page> pages) =>
|
||||
[.. pages.Select(page => new NavLinkItem(HrefFor(page.Slug), page.Title))];
|
||||
}
|
||||
Reference in new issue
Block a user