feat(windkarte): wind_map referenziert wind_area explizit
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user