refactor(post-events): read event data from resolved calendarItem
Replace direct post.isEvent/eventDate/eventLocation reads with getPostEventInfo() helper that derives info from the resolved calendarItem reference. Loaders now resolve "calendarItem" and request that field instead of legacy flat properties. Also regenerate iconify mdi subset (map-marker-outline, download, google, calendar-search, refresh). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import Tag from "./Tag.svelte";
|
||||
import Pagination from "./Pagination.svelte";
|
||||
import type { PostEntry } from "$lib/cms";
|
||||
import { postHref } from "$lib/blog-utils";
|
||||
import { postHref, getPostEventInfo } from "$lib/blog-utils";
|
||||
import { t as tStatic, T } from "$lib/translations";
|
||||
import type { Translations } from "$lib/translations";
|
||||
import {
|
||||
@@ -34,8 +34,6 @@
|
||||
eventDate: string | null;
|
||||
};
|
||||
|
||||
type EventPost = PostEntry & { eventDate?: string; isEvent?: boolean };
|
||||
|
||||
let {
|
||||
posts = [],
|
||||
tags = [],
|
||||
@@ -56,7 +54,7 @@
|
||||
totalPosts?: number;
|
||||
basePath?: string;
|
||||
translations?: Translations | null;
|
||||
upcomingEvents?: EventPost[];
|
||||
upcomingEvents?: PostEntry[];
|
||||
searchIndex?: SearchIndexEntry[] | null;
|
||||
} = $props();
|
||||
|
||||
@@ -193,12 +191,13 @@
|
||||
</h2>
|
||||
<ul class="not-prose list-none space-y-2 pl-0">
|
||||
{#each upcomingEvents as ev}
|
||||
{@const evInfo = getPostEventInfo(ev)}
|
||||
<li>
|
||||
<a
|
||||
href={postHref(ev)}
|
||||
class="group flex flex-wrap items-center gap-2 no-underline"
|
||||
>
|
||||
<EventBadges eventDate={ev.eventDate} />
|
||||
<EventBadges eventDate={evInfo.eventDate} />
|
||||
<span
|
||||
class="text-sm text-stein-900 group-hover:text-stein-900"
|
||||
>{ev.headline}</span
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import EventBadges from "./EventBadges.svelte";
|
||||
import RustyImage from "./RustyImage.svelte";
|
||||
import Card from "./Card.svelte";
|
||||
import { getPostEventInfo } from "$lib/blog-utils";
|
||||
import { useTranslate, T } from "$lib/translations";
|
||||
|
||||
const t = useTranslate();
|
||||
@@ -33,15 +34,9 @@
|
||||
const focal = $derived(post._imageFocal ?? null);
|
||||
const fallbackImg = $derived(post._resolvedImageUrl);
|
||||
|
||||
type PostWithEvent = PostWithImage & {
|
||||
isEvent?: boolean;
|
||||
eventDate?: string;
|
||||
eventLocation?: { text?: string };
|
||||
};
|
||||
const p = $derived(post as PostWithEvent);
|
||||
|
||||
const eventDate = $derived(p.isEvent && p.eventDate ? p.eventDate : null);
|
||||
const locationText = $derived(p.eventLocation?.text ?? null);
|
||||
const eventInfo = $derived(getPostEventInfo(post));
|
||||
const eventDate = $derived(eventInfo.eventDate);
|
||||
const locationText = $derived(eventInfo.eventLocation?.text ?? null);
|
||||
|
||||
const tagSlugs = $derived(
|
||||
(post.postTag ?? []).map((t) =>
|
||||
@@ -50,7 +45,7 @@
|
||||
);
|
||||
const hasTerminTag = $derived(tagSlugs.includes("tag-termin"));
|
||||
const isPastEvent = $derived(
|
||||
hasTerminTag && !!p.eventDate && new Date(p.eventDate).getTime() < Date.now(),
|
||||
hasTerminTag && !!eventDate && new Date(eventDate).getTime() < Date.now(),
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user