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,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