your personal website on atproto - mirror blento.app
25
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #288 from flo-bit/fix-sections-500

fix 500

authored by

Florian and committed by
GitHub
1120673f 67ae4c7e

+22 -8
+6 -1
src/lib/sections/HeroSection/Decoration.svelte
··· 21 21 onclick?: () => void; 22 22 } = $props(); 23 23 24 - const selectedCardId = getSelectedCardId(); 24 + let selectedCardId: (() => string | null) | null = null; 25 + try { 26 + selectedCardId = getSelectedCardId(); 27 + } catch { 28 + // not set in read-only Website context 29 + } 25 30 let isSelected = $derived(!!item && selectedCardId?.() === item.id); 26 31 27 32 let rotation = $derived(item?.rotation ?? slot.rotation ?? 0);
+16 -7
src/lib/website/load.ts
··· 622 622 const cards = data.cards.filter((v) => v.page === data.page); 623 623 624 624 if (cards.length > 0) { 625 - // Detect overlaps before fixing — flag is surfaced by the edit UI 626 - // so the user knows their layout was auto-adjusted. 627 - data.hasLayoutIssue = hasOverlaps(cards, false) || hasOverlaps(cards, true); 625 + const bySection = new Map<string | undefined, Item[]>(); 626 + for (const card of cards) { 627 + const key = card.sectionId; 628 + const bucket = bySection.get(key); 629 + if (bucket) bucket.push(card); 630 + else bySection.set(key, [card]); 631 + } 628 632 629 - fixAllCollisions(cards, false); 630 - fixAllCollisions(cards, true); 631 - compactItems(cards, false); 632 - compactItems(cards, true); 633 + let hasLayoutIssue = false; 634 + for (const sectionCards of bySection.values()) { 635 + hasLayoutIssue ||= hasOverlaps(sectionCards, false) || hasOverlaps(sectionCards, true); 636 + fixAllCollisions(sectionCards, false); 637 + fixAllCollisions(sectionCards, true); 638 + compactItems(sectionCards, false); 639 + compactItems(sectionCards, true); 640 + } 641 + data.hasLayoutIssue = hasLayoutIssue; 633 642 } 634 643 635 644 data.cards = cards;