feat(windkarte): wind_map referenziert wind_area explizit
Deploy / verify (push) Successful in 49s
Deploy / deploy (push) Successful in 1m1s

areas-Feld im Schema + Block-Logik: referenzierte Slugs werden einzeln
gefetcht. Leer = alle published areas als Fallback. Ermöglicht verschiedene
Karten-Blöcke mit unterschiedlichen Gebiet-Subsets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Peter Meier
2026-05-13 09:25:00 +02:00
parent 39d7d70c8b
commit 067e847524
2 changed files with 25 additions and 6 deletions
+2
View File
@@ -428,4 +428,6 @@ export interface WindMapBlockData {
name?: string;
title?: string;
subtitle?: string;
/** Explizite Auswahl von wind_area-Slugs. Leer/null = alle published areas. */
areas?: (string | { _slug: string;[key: string]: unknown })[];
}
@@ -25,12 +25,29 @@
onMount(async () => {
try {
const res = await fetch(`${CMS_BASE}/api/content/wind_area?limit=100`, {
signal: AbortSignal.timeout(6_000),
});
if (res.ok) {
const data = await res.json();
areas = data.items ?? [];
const slugs = (block.areas ?? [])
.map((a) => (typeof a === "string" ? a : a._slug))
.filter(Boolean);
if (slugs.length > 0) {
// Fetch only the explicitly referenced areas in parallel
const results = await Promise.all(
slugs.map((slug) =>
fetch(`${CMS_BASE}/api/content/wind_area/${slug}`, {
signal: AbortSignal.timeout(6_000),
}).then((r) => (r.ok ? r.json() : null))
)
);
areas = results.filter((r): r is WindArea => r !== null);
} else {
// Fallback: all published areas
const res = await fetch(`${CMS_BASE}/api/content/wind_area?limit=100`, {
signal: AbortSignal.timeout(6_000),
});
if (res.ok) {
const data = await res.json();
areas = data.items ?? [];
}
}
} catch {
// Map renders without CMS metadata — GeoJSON tooltips still work