Luat: editing and personalisation
Preview and drafts
The editor opens the site in its canvas and proves who the author is with the preview handshake: the studio-preview route turns a short-lived grant into a signed, HttpOnly, partitioned cookie. Only that signed session makes a request read the working branch and the author’s draft; ?studio-edit=1 alone turns on the edit chrome but never changes what is read. The session format is the one the JavaScript sites use, so a Luat and a SvelteKit renderer sharing STUDIO_PREVIEW_SECRET accept each other’s sessions.
While a page is open in the editor, every response is noindex and never cached, and the page may be framed by the editor’s origin (add more origins with STUDIO_EDITOR_ORIGINS). After each edit the editor asks the page to re-render: the server renders it again with the draft, and the changed regions are swapped in place.
Personalisation
Everything is resolved on the server, per request, with the same rules engine as the JavaScript libraries:
- Block variants (
standard:Variants,standard:Switcher):load_pagepicks the variant for the visitor before the page renders. In the editor the variants are left in place so the author can edit each one. - Page variations (
studio:PageVariation): a whole alternative page under the same URL, picked by its rule;?studio-variant=previews one. - Segments: managed audiences (
studio:Audience) are resolved into the visitor context, so rules can saysegments.contains('dach'). - Persona preview: inside a preview session,
?persona=<name>renders the page as that persona.
The visitor context is built from the request — language, country (from the edge), device class, time — plus the resolved segments; s:visitor(rc, ctx) returns it if your own code needs it. Rules that depend on the visitor change the page’s caching headers automatically: Vary: X-Country-Code for country rules, private, no-store for per-visitor rules.
One difference to the JavaScript sites: a Luat page has no client-side re-pick, so rules on time.* use the server clock.
Reference
The package README in the Studio repository (packages/studio-luat/README.md) lists every call and module. The modules are ports of @maravilla/studio-content and are tested against vectors produced by the JavaScript code.
Pilot documentation. Studio is in a partner pilot. Screens and YAML shown here are current as of the version noted on each page; tell your Maravilla contact when something does not match what you see.