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
@@ -0,0 +1,39 @@
|
||||
using Elternbeirat.Contracts;
|
||||
using Elternbeirat.Web.Features.Layout;
|
||||
using Elternbeirat.Web.Shared;
|
||||
|
||||
namespace Elternbeirat.Web.Features.Home;
|
||||
|
||||
/// <summary>
|
||||
/// One tile on the home page, leading to a section of the site.
|
||||
/// </summary>
|
||||
/// <param name="Href">Target URL of the page.</param>
|
||||
/// <param name="Title">The page's title.</param>
|
||||
/// <param name="Description">
|
||||
/// The first sentence of the page's body, or an empty string, in which case the
|
||||
/// tile shows only the title.
|
||||
/// </param>
|
||||
/// <param name="Icon">The icon name, see <see cref="TileIcons"/>.</param>
|
||||
public sealed record HomeTile(string Href, string Title, string Description, string Icon)
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds one tile per header page except the home page itself.
|
||||
/// </summary>
|
||||
/// <param name="pages">All public pages.</param>
|
||||
/// <returns>The tiles, in menu order.</returns>
|
||||
/// <remarks>
|
||||
/// The tiles mirror the header menu (<see cref="NavBuilder.HeaderPages"/>), so a
|
||||
/// page an editor puts into the header appears here too, without any code. The
|
||||
/// home page is left out: a tile leading to the page it sits on would be useless.
|
||||
/// </remarks>
|
||||
public static IReadOnlyList<HomeTile> From(IReadOnlyList<Page> pages) =>
|
||||
[
|
||||
.. NavBuilder.HeaderPages(pages)
|
||||
.Where(page => !Page.IsHomeSlug(page.Slug))
|
||||
.Select(page => new HomeTile(
|
||||
NavBuilder.HrefFor(page.Slug),
|
||||
page.Title,
|
||||
Markdown.FirstSentence(page.Body),
|
||||
TileIcons.For(page.Slug))),
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user