diff --git a/aidlc-docs/features/redesign-modern-timetravel/audit.md b/aidlc-docs/features/redesign-modern-timetravel/audit.md index 97feb2a..a26a147 100644 --- a/aidlc-docs/features/redesign-modern-timetravel/audit.md +++ b/aidlc-docs/features/redesign-modern-timetravel/audit.md @@ -754,3 +754,15 @@ **Context**: Interim test build; CMS pipeline coordination. --- + +## Interim Deploy 2 and SEO Unit Added + +**Timestamp**: 2026-11-11T11:00:00Z + +**User Input**: "Ik wil de nieuwe changes ook deployen naar test zodat ik het kan testen. over de SEO-unit. voeg die toe, maar exacte keuzes wil ik nu nog niet maken. De inhoud van de website wordt deels of helemaal dynamisch dus ik vraag mij af of pre-redneren dan wel de juiste keuze is." + +**AI Response**: "Pushed 1681d03 and dispatched a test-only deploy (run 644, queued behind the PR run). Added unit U6 seo-and-performance to unit-of-work.md with a considerations document (current state, five options A-E, open questions); no technical choice made. Key point: build-time prerendering freezes dynamic content until the next build, so it fits only content that changes with releases; the CMS host already has a PrerenderedPages mode (Andrea) which is a candidate for dynamic content." + +**Context**: Interim deploy and unit planning. + +--- diff --git a/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-of-work.md b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-of-work.md index 4461113..1be3430 100644 --- a/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-of-work.md +++ b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-of-work.md @@ -36,6 +36,11 @@ - **Design stages**: NFR Requirements and NFR Design (performance with effects, accessibility). No Functional Design (design exists). - **Requirements**: FR-2, FR-12 (E part), FR-19 (E part), NFR-1, NFR-2, NFR-3. +### U6 — seo-and-performance (added 2026-11-11, choices open) +- **Purpose**: findability and speed of the public pages (prerendering or server rendering of content, structured data, robots/sitemap/meta per environment, measured performance budgets). +- **Status**: scope and options only, see `unit-u6-seo-and-performance.md`; **no technical choice made**; comes after U5 unless the owner moves it. Whether pre-rendering is the right approach depends on how dynamic the content becomes (open question 1). +- **Requirements**: new NFR group (to be added when planned). + ## External units (CMS builder, SlpModularCms — feature `contact-forms-module`) | Id | Content | Base | |---|---|---| diff --git a/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-u6-seo-and-performance.md b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-u6-seo-and-performance.md new file mode 100644 index 0000000..6576c94 --- /dev/null +++ b/aidlc-docs/features/redesign-modern-timetravel/inception/application-design/unit-u6-seo-and-performance.md @@ -0,0 +1,37 @@ +# Unit U6 — SEO and performance (added 2026-11-11, choices deliberately open) + +Added at the request of the product owner after the interim test build. **No technical choices have been made yet**; this document records the goal, the current state, the options and the questions to settle before the unit is planned. Position in the order: after U5 (variant E), unless the owner moves it. + +## Goal +Make the public pages findable and fast: content visible to crawlers and to link previews without relying on JavaScript timing, structured data for the business and its packages, sensible indexing per environment, and measured performance budgets. + +## Current state (measured or read from the code, 2026-11-11) +- Client-rendered SPA (React, Vite, hash routing, one page). `index.html` contains only title, description and `lang="nl"`; hero, about, process and contact text are rendered by JavaScript. Packages are fetched from `/api/v1/offerings` after load. +- Build output: JS 467 kB (152 kB gzip), CSS 59 kB; variant E is a separate lazy chunk; fonts self-hosted; the about photo is lazy with WebP variants. +- Missing: `robots.txt`, `sitemap.xml`, canonical URL, Open Graph/Twitter tags, structured data (JSON-LD), favicon set. Test and production share one bundle, so nothing environment-specific (such as "do not index test") can be baked into the build today. +- Accessibility is covered by unit tests (landmarks, contrast, focus, skip link); no Lighthouse or real screen-reader run has been done yet. + +## The central question: is pre-rendering the right choice when the content becomes (partly) dynamic? +Pre-rendering at **build time** freezes the content at the moment of the build. If packages (and later more text) come from the CMS, the HTML would be stale until the next build, unless a CMS change triggers a rebuild. So build-time pre-rendering is only right for content that changes together with a release. + +Options to compare (none chosen): +| Option | What it is | Fresh content | Cost / risk | +|---|---|---|---| +| A. Build-time prerender of the static parts only | Hero, about, process, contact text in the HTML at build; dynamic blocks (packages) still client-side | static parts yes, dynamic no | small; packages stay invisible to crawlers that do not run JS | +| B. Build-time prerender plus a data snapshot | Build fetches the offerings and bakes them in; client refreshes on load | stale until rebuild; needs a rebuild trigger on CMS change | pipeline coupling to the CMS API | +| C. Render in the CMS host on request or on publish | The .NET host that already serves the site (WebsiteMode `SpaFallback` for SLP; `PrerenderedPages` exists for the Andrea host) serves HTML that includes current data | yes | server-side work in the CMS repo; follows the pattern already used for Andrea | +| D. Client-only with JS-injected structured data | Keep the SPA; add JSON-LD, meta tags and sitemap, generated from the API data in the browser | yes, but depends on the crawler rendering JS | cheapest; weakest guarantee | +| E. Hybrid (A for static text + D or C for data) | Static text prerendered; dynamic parts via C or D | mixed | most flexible; two mechanisms | + +## Elements that are independent of that choice +`robots.txt` and indexing rules per environment (test must not be indexed), `sitemap.xml`, canonical URL, Open Graph/Twitter tags, favicon set, JSON-LD for the organisation, performance budget and a Lighthouse CI/measurement step, image dimensions and `fetchpriority` on the LCP element, font preloading for the display face. + +## Questions to settle before planning (not asked yet) +1. Which parts of the page will really be dynamic, and how often do they change (packages only, or also texts)? +2. Who serves the public HTML for SLP Software in production (the CMS host fallback or a separate static server), and can that host render HTML itself? +3. How strict must "fresh within minutes" be for crawlers, versus "fresh at the next release"? +4. How should test environments be kept out of search results (robots, headers, auth)? +5. Is a measured Lighthouse score a release gate? + +## Requirements touched +New NFR group "SEO and performance" to be added to `requirements.md` when the unit is planned. Security Baseline applies to any new header or script (CSP, no new third-party scripts). diff --git a/src/shared/packages/useSwipeRow.ts b/src/shared/packages/useSwipeRow.ts index fffa3c6..44bf674 100644 --- a/src/shared/packages/useSwipeRow.ts +++ b/src/shared/packages/useSwipeRow.ts @@ -24,7 +24,11 @@ function scrollLeftFor(container: HTMLElement, index: number): number { */ export function useSwipeRow(itemCount: number, initialIndex: number, resetKey: string) { const ref = useRef(null); - const [activeIndex, setActiveIndex] = useState(initialIndex); + // The active card is derived for the current set of cards (key), so it is already correct in + // the first render after the data or the filter changed (no effect, no flicker, no race). + const key = `${initialIndex}|${itemCount}|${resetKey}`; + const [active, setActive] = useState({ key, index: initialIndex }); + const activeIndex = active.key === key ? active.index : initialIndex; const reducedMotion = usePrefersReducedMotion(); const scrollToIndex = useCallback( @@ -39,9 +43,9 @@ export function useSwipeRow(itemCount: number, initialIndex: number, resetKey: s } else { container.scrollLeft = left; } - setActiveIndex(index); + setActive({ key, index }); }, - [reducedMotion], + [reducedMotion, key], ); // Start position: featured card (or first) whenever the set of cards changes. @@ -50,7 +54,6 @@ export function useSwipeRow(itemCount: number, initialIndex: number, resetKey: s if (container) { container.scrollLeft = scrollLeftFor(container, initialIndex); } - setActiveIndex(initialIndex); }, [initialIndex, itemCount, resetKey]); // Follow the scroll position for the dots (throttled to animation frames). @@ -63,13 +66,14 @@ export function useSwipeRow(itemCount: number, initialIndex: number, resetKey: s const onScroll = () => { cancelAnimationFrame(frame); frame = requestAnimationFrame(() => { - setActiveIndex( - activeIndexFromScroll( + setActive({ + key, + index: activeIndexFromScroll( container.scrollLeft, container.clientWidth, cardMetrics(container), ), - ); + }); }); }; container.addEventListener('scroll', onScroll, { passive: true }); @@ -77,7 +81,7 @@ export function useSwipeRow(itemCount: number, initialIndex: number, resetKey: s cancelAnimationFrame(frame); container.removeEventListener('scroll', onScroll); }; - }, [itemCount]); + }, [itemCount, key]); return { ref, activeIndex, scrollToIndex }; }