@sanity/routes
    Preparing search index...

    Function createSlugWithUrlPreview

    • 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).

      Parameters

      • options: SlugUrlPreviewOptions = {}

        Configuration options. When channel is omitted, queries for the default config (isDefault: true). When specified, queries for the named channel.

      Returns (props: SlugInputProps) => Element

      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 },
      })
      import {createSlugWithUrlPreview} from '@sanity/routes/studio'

      const SlugWithUrlPreview = createSlugWithUrlPreview({ channel: 'web' })

      defineField({
      name: 'slug',
      type: 'slug',
      options: { source: 'title' },
      components: { input: SlugWithUrlPreview },
      })