Extract date rendering into per-feature Date components
This commit is contained in:
1 parent
d95bf0dcbe
commit
455b603299
16 files changed
+168
-71
No files matched your search
@@ -1,12 +1,13 @@
|
||||
@if (_upcoming.Count > 0)
|
||||
@using Elternbeirat.Web.Features.Events
|
||||
@if (_upcomingEvents.Count > 0)
|
||||
{
|
||||
<section class="embed embed-events">
|
||||
<h2>Kommende Termine</h2>
|
||||
<ul class="event-list">
|
||||
@foreach (var ev in _upcoming)
|
||||
@foreach (var ev in _upcomingEvents)
|
||||
{
|
||||
<li>
|
||||
<time datetime="@ev.Start.ToString("s")">@EventFormat.Range(ev)</time>
|
||||
<EventDate Value="ev" />
|
||||
<span class="event-title">@ev.Title</span>
|
||||
@if (!string.IsNullOrWhiteSpace(ev.Location))
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ public partial class EventsEmbed
|
||||
[CascadingParameter]
|
||||
private HttpContext? HttpContext { get; set; }
|
||||
|
||||
private IReadOnlyList<Event> _upcoming = [];
|
||||
private IReadOnlyList<Event> _upcomingEvents = [];
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -45,7 +45,7 @@ public partial class EventsEmbed
|
||||
// Teaser: the soonest upcoming events, earliest first. An event earlier
|
||||
// today still counts as upcoming.
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
_upcoming =
|
||||
_upcomingEvents =
|
||||
[
|
||||
.. events
|
||||
.Where(@event => DateOnly.FromDateTime(@event.Start) >= today)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@using Elternbeirat.Web.Features.Posts
|
||||
@if (_latest.Count > 0)
|
||||
{
|
||||
<section class="embed embed-posts">
|
||||
@@ -7,9 +8,7 @@
|
||||
{
|
||||
<li>
|
||||
<a href="@($"/posts/{post.Slug}")">@post.Title</a>
|
||||
<time datetime="@post.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)">
|
||||
@post.Date.ToString("d. MMMM yyyy", Cultures.German)
|
||||
</time>
|
||||
<PostDate Value="post.Date" />
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
Reference in new issue
Block a user