Updates the packages and the banner live in the browser
The build still bakes the current packages and the active banner into the HTML. After hydration the page asks /api/v1/offerings and /api/v1/offerings/banner once and replaces what differs; errors and time-outs keep what was baked, and a 204 from the banner route hides the banner. The banner is now the OfferingBanner contract (title, text, optional link) instead of layout=banner. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
|
||||
import { createRootRoute, HeadContent, Scripts } from '@tanstack/react-router';
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
import AppShell from '../components/AppShell';
|
||||
import PackagesProvider from '../components/PackagesProvider/PackagesProvider';
|
||||
import NoScriptStyles from '../components/NoScript/NoScriptStyles';
|
||||
import ErrorPage from '../components/StatusPage/ErrorPage';
|
||||
import NotFound from '../components/StatusPage/NotFound';
|
||||
@@ -42,12 +43,12 @@ const RootDocument = ({ children }: { children: ReactNode }) => (
|
||||
);
|
||||
|
||||
const RootLayout = () => (
|
||||
<>
|
||||
<PackagesProvider>
|
||||
<AppShell />
|
||||
<Suspense>
|
||||
<RouterDevtools />
|
||||
</Suspense>
|
||||
</>
|
||||
</PackagesProvider>
|
||||
);
|
||||
|
||||
export const Route = createRootRoute({
|
||||
|
||||
@@ -10,7 +10,7 @@ import PageIntro from '../components/PageIntro/PageIntro';
|
||||
import PageSection from '../components/PageSection/PageSection';
|
||||
import Reveal from '../components/Reveal/Reveal';
|
||||
import contactContent from '../content/contactContent';
|
||||
import packages from '../content/packages';
|
||||
import { usePackages } from '../components/PackagesProvider/PackagesProvider';
|
||||
import siteContent from '../content/siteContent';
|
||||
import { withReplyTime } from '../lib/withReplyTime';
|
||||
import useHydrated from '../hooks/useHydrated';
|
||||
@@ -50,6 +50,7 @@ export const Route = createFileRoute('/contact')({
|
||||
// form (BR-CP-01..04). The card is in the page twice, one per layout, so the
|
||||
// reading order always matches what is shown.
|
||||
function Contact() {
|
||||
const packages = usePackages();
|
||||
const { pakket: searched } = Route.useSearch();
|
||||
// The search only counts after hydration, so the prerendered HTML and the
|
||||
// first browser render agree (BR-HYD-10)
|
||||
|
||||
@@ -9,7 +9,10 @@ import IntroGallery from '../components/home/IntroGallery/IntroGallery';
|
||||
import heroContent from '../content/heroContent';
|
||||
import homeContent from '../content/homeContent';
|
||||
import instagramContent from '../content/instagramContent';
|
||||
import packages, { banner } from '../content/packages';
|
||||
import {
|
||||
useBanner,
|
||||
usePackages,
|
||||
} from '../components/PackagesProvider/PackagesProvider';
|
||||
import testimonials from '../content/testimonials';
|
||||
import siteContent from '../content/siteContent';
|
||||
import { visibleSocials } from '../lib/visibleSocials';
|
||||
@@ -29,6 +32,8 @@ export const Route = createFileRoute('/')({
|
||||
|
||||
// The homepage: the hero, then the sections in the order of LAYOUT.md
|
||||
function Index() {
|
||||
const packages = usePackages();
|
||||
const banner = useBanner();
|
||||
const { pakket: searched } = Route.useSearch();
|
||||
// The search only counts after hydration, so the prerendered HTML and the
|
||||
// first browser render agree (BR-HYD-10)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { useMemo } from 'react';
|
||||
import { usePackages } from '../../components/PackagesProvider/PackagesProvider';
|
||||
import type { ShootPageSources } from '../../lib/shootPageView';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
|
||||
// The sources of a shoot page with the packages as they are now (baked, or
|
||||
// live once the browser got the CMS answer)
|
||||
export function useShootPageSources(): ShootPageSources {
|
||||
const packages = usePackages();
|
||||
return useMemo(() => ({ ...shootPageSources, packages }), [packages]);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import gezinPage from '../../content/shootPages/gezin';
|
||||
import siteContent from '../../content/siteContent';
|
||||
import { shootPageView } from '../../lib/shootPageView';
|
||||
import { pageHead, shootPageGraph } from '../../seo';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
import { useShootPageSources } from './-useShootPageSources';
|
||||
|
||||
export const Route = createFileRoute('/soorten-fotoshoots/gezin')({
|
||||
head: () => pageHead('/soorten-fotoshoots/gezin'),
|
||||
@@ -17,7 +17,8 @@ export const Route = createFileRoute('/soorten-fotoshoots/gezin')({
|
||||
// part of the main bundle, the component is split off, so the page texts
|
||||
// only load with this page.
|
||||
function GezinPage() {
|
||||
const view = shootPageView('gezin', gezinPage, shootPageSources);
|
||||
const sources = useShootPageSources();
|
||||
const view = shootPageView('gezin', gezinPage, sources);
|
||||
if (view === undefined) return <NotFound />;
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -5,7 +5,7 @@ import PageIntro from '../../components/PageIntro/PageIntro';
|
||||
import RichParagraph from '../../components/RichParagraph/RichParagraph';
|
||||
import ShootList from '../../components/shoots/ShootList/ShootList';
|
||||
import StructuredData from '../../components/StructuredData/StructuredData';
|
||||
import packages from '../../content/packages';
|
||||
import { usePackages } from '../../components/PackagesProvider/PackagesProvider';
|
||||
import portfolioContent from '../../content/portfolioContent';
|
||||
import shootTypes from '../../content/shootTypes';
|
||||
import shootTypesPageContent from '../../content/shootTypesPageContent';
|
||||
@@ -23,6 +23,7 @@ export const Route = createFileRoute('/soorten-fotoshoots/')({
|
||||
// The shoot types page: the page head, the shoots one by one and a closing
|
||||
// call to action, in the order of LAYOUT.md
|
||||
function PhotoshootTypes() {
|
||||
const packages = usePackages();
|
||||
const { head, closing } = shootTypesPageContent;
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -6,7 +6,7 @@ import loveshootPage from '../../content/shootPages/loveshoot';
|
||||
import siteContent from '../../content/siteContent';
|
||||
import { shootPageView } from '../../lib/shootPageView';
|
||||
import { pageHead, shootPageGraph } from '../../seo';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
import { useShootPageSources } from './-useShootPageSources';
|
||||
|
||||
export const Route = createFileRoute('/soorten-fotoshoots/loveshoot')({
|
||||
head: () => pageHead('/soorten-fotoshoots/loveshoot'),
|
||||
@@ -17,7 +17,8 @@ export const Route = createFileRoute('/soorten-fotoshoots/loveshoot')({
|
||||
// part of the main bundle, the component is split off, so the page texts
|
||||
// only load with this page.
|
||||
function LoveshootPage() {
|
||||
const view = shootPageView('loveshoot', loveshootPage, shootPageSources);
|
||||
const sources = useShootPageSources();
|
||||
const view = shootPageView('loveshoot', loveshootPage, sources);
|
||||
if (view === undefined) return <NotFound />;
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -6,7 +6,7 @@ import newbornPage from '../../content/shootPages/newborn';
|
||||
import siteContent from '../../content/siteContent';
|
||||
import { shootPageView } from '../../lib/shootPageView';
|
||||
import { pageHead, shootPageGraph } from '../../seo';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
import { useShootPageSources } from './-useShootPageSources';
|
||||
|
||||
export const Route = createFileRoute('/soorten-fotoshoots/newborn')({
|
||||
head: () => pageHead('/soorten-fotoshoots/newborn'),
|
||||
@@ -17,7 +17,8 @@ export const Route = createFileRoute('/soorten-fotoshoots/newborn')({
|
||||
// part of the main bundle, the component is split off, so the page texts
|
||||
// only load with this page.
|
||||
function NewbornPage() {
|
||||
const view = shootPageView('newborn', newbornPage, shootPageSources);
|
||||
const sources = useShootPageSources();
|
||||
const view = shootPageView('newborn', newbornPage, sources);
|
||||
if (view === undefined) return <NotFound />;
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -6,7 +6,7 @@ import portretPage from '../../content/shootPages/portret';
|
||||
import siteContent from '../../content/siteContent';
|
||||
import { shootPageView } from '../../lib/shootPageView';
|
||||
import { pageHead, shootPageGraph } from '../../seo';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
import { useShootPageSources } from './-useShootPageSources';
|
||||
|
||||
export const Route = createFileRoute('/soorten-fotoshoots/portret')({
|
||||
head: () => pageHead('/soorten-fotoshoots/portret'),
|
||||
@@ -17,7 +17,8 @@ export const Route = createFileRoute('/soorten-fotoshoots/portret')({
|
||||
// part of the main bundle, the component is split off, so the page texts
|
||||
// only load with this page.
|
||||
function PortretPage() {
|
||||
const view = shootPageView('portret', portretPage, shootPageSources);
|
||||
const sources = useShootPageSources();
|
||||
const view = shootPageView('portret', portretPage, sources);
|
||||
if (view === undefined) return <NotFound />;
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -6,7 +6,7 @@ import zwangerschapPage from '../../content/shootPages/zwangerschap';
|
||||
import siteContent from '../../content/siteContent';
|
||||
import { shootPageView } from '../../lib/shootPageView';
|
||||
import { pageHead, shootPageGraph } from '../../seo';
|
||||
import { shootPageSources } from './-shootPageSources';
|
||||
import { useShootPageSources } from './-useShootPageSources';
|
||||
|
||||
export const Route = createFileRoute('/soorten-fotoshoots/zwangerschap')({
|
||||
head: () => pageHead('/soorten-fotoshoots/zwangerschap'),
|
||||
@@ -17,11 +17,8 @@ export const Route = createFileRoute('/soorten-fotoshoots/zwangerschap')({
|
||||
// part of the main bundle, the component is split off, so the page texts
|
||||
// only load with this page.
|
||||
function ZwangerschapPage() {
|
||||
const view = shootPageView(
|
||||
'zwangerschap',
|
||||
zwangerschapPage,
|
||||
shootPageSources,
|
||||
);
|
||||
const sources = useShootPageSources();
|
||||
const view = shootPageView('zwangerschap', zwangerschapPage, sources);
|
||||
if (view === undefined) return <NotFound />;
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user