Creates a slug input component that shows the resolved URL prefix above the slug field.
Wraps the default slug input and reactively queries the route config to assemble the full URL prefix (baseUrl + basePath + optional parent slug).
Handles both simpleSlug mode (basePath only) and parentSlug mode (basePath + parent document's slug).
simpleSlug
parentSlug
Configuration options. When channel is omitted, queries for the default config (isDefault: true). When specified, queries for the named channel.
channel
isDefault: true
A React component suitable for use as a slug field input.
import {SlugWithUrlPreview} from '@sanity/routes/studio'defineField({ name: 'slug', type: 'slug', options: { source: 'title' }, components: { input: SlugWithUrlPreview },}) Copy
import {SlugWithUrlPreview} from '@sanity/routes/studio'defineField({ name: 'slug', type: 'slug', options: { source: 'title' }, components: { input: SlugWithUrlPreview },})
import {createSlugWithUrlPreview} from '@sanity/routes/studio'const SlugWithUrlPreview = createSlugWithUrlPreview({ channel: 'web' })defineField({ name: 'slug', type: 'slug', options: { source: 'title' }, components: { input: SlugWithUrlPreview },}) Copy
import {createSlugWithUrlPreview} from '@sanity/routes/studio'const SlugWithUrlPreview = createSlugWithUrlPreview({ channel: 'web' })defineField({ name: 'slug', type: 'slug', options: { source: 'title' }, components: { input: SlugWithUrlPreview },})
Creates a slug input component that shows the resolved URL prefix above the slug field.
Wraps the default slug input and reactively queries the route config to assemble the full URL prefix (baseUrl + basePath + optional parent slug).
Handles both
simpleSlugmode (basePath only) andparentSlugmode (basePath + parent document's slug).