From 3411965e6201ed838e3ebe0fe8d20b4dec8b6ab6 Mon Sep 17 00:00:00 2001 From: kulesy Date: Wed, 23 Sep 2026 06:05:55 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=20Add=20the=20ui.router=20step=20t?= =?UTF-8?q?o=20the=20Astro=20visual=20editing=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_016pUr8ww27HZoGfinGEsZot --- content/docs/contextual-editing/astro.mdx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content/docs/contextual-editing/astro.mdx b/content/docs/contextual-editing/astro.mdx index 49f3b39f..e9f1fe9a 100644 --- a/content/docs/contextual-editing/astro.mdx +++ b/content/docs/contextual-editing/astro.mdx @@ -207,6 +207,23 @@ if (!data) return new Response('Not Found', { status: 404 }); ``` +## Point each collection at its page + +The admin only opens the visual editor when it knows which URL a document renders at. Set `ui.router` on every collection you want to edit visually, or clicking a document opens the full-page form with no live preview. + +```ts +// tina/collections/page.ts +export const PageCollection = { + // ... + ui: { + router: ({ document }) => + document._sys.filename === 'home' ? '/' : `/${document._sys.filename}`, + }, +}; +``` + +See [Visual Editing Router](/docs/contextual-editing/router/) for the full signature. + ## Add field-level click-to-edit `tinaField()` returns a string identifying which form field a DOM element corresponds to. Stamp it on any element you want clickable in the editor: