From 7f6505bcecb19274d9cce4a17d5b7f1ed3b4b10e Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Sat, 18 Apr 2026 10:53:49 +0200 Subject: [PATCH] fix 500 --- .../sections/HeroSection/Decoration.svelte | 7 +++++- src/lib/website/load.ts | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/lib/sections/HeroSection/Decoration.svelte b/src/lib/sections/HeroSection/Decoration.svelte index 8b2741a..b579329 100644 --- a/src/lib/sections/HeroSection/Decoration.svelte +++ b/src/lib/sections/HeroSection/Decoration.svelte @@ -21,7 +21,12 @@ onclick?: () => void; } = $props(); - const selectedCardId = getSelectedCardId(); + let selectedCardId: (() => string | null) | null = null; + try { + selectedCardId = getSelectedCardId(); + } catch { + // not set in read-only Website context + } let isSelected = $derived(!!item && selectedCardId?.() === item.id); let rotation = $derived(item?.rotation ?? slot.rotation ?? 0); diff --git a/src/lib/website/load.ts b/src/lib/website/load.ts index ee908df..bef183c 100644 --- a/src/lib/website/load.ts +++ b/src/lib/website/load.ts @@ -622,14 +622,23 @@ function checkData(data: WebsiteData): WebsiteData { const cards = data.cards.filter((v) => v.page === data.page); if (cards.length > 0) { - // Detect overlaps before fixing — flag is surfaced by the edit UI - // so the user knows their layout was auto-adjusted. - data.hasLayoutIssue = hasOverlaps(cards, false) || hasOverlaps(cards, true); - - fixAllCollisions(cards, false); - fixAllCollisions(cards, true); - compactItems(cards, false); - compactItems(cards, true); + const bySection = new Map(); + for (const card of cards) { + const key = card.sectionId; + const bucket = bySection.get(key); + if (bucket) bucket.push(card); + else bySection.set(key, [card]); + } + + let hasLayoutIssue = false; + for (const sectionCards of bySection.values()) { + hasLayoutIssue ||= hasOverlaps(sectionCards, false) || hasOverlaps(sectionCards, true); + fixAllCollisions(sectionCards, false); + fixAllCollisions(sectionCards, true); + compactItems(sectionCards, false); + compactItems(sectionCards, true); + } + data.hasLayoutIssue = hasLayoutIssue; } data.cards = cards; -- 2.51.2