@sanity/routes
    Preparing search index...

    Function routesPresentation

    • Auto-generate Presentation tool resolve config from route configuration.

      Reads route config + route map shards from the Content Lake to generate document locations reactively. When a document's route or the route config changes, the location updates automatically via listenQuery.

      locations (document → URL): Uses a DocumentLocationResolver function that queries the route map shard for the document's type. The route map contains pre-computed paths, so no client-side GROQ evaluation is needed.

      mainDocuments (URL → document): Optionally accepts static entries via options.mainDocuments. These can't be generated dynamically because the Presentation tool needs them at config time.

      Parameters

      • channel: string

        The route config channel (e.g., 'web')

      • Optionaloptions: RoutesPresentationOptions

        Optional overrides for extra locations and mainDocuments

      Returns any

      Object with locations (and optionally mainDocuments) for the Presentation tool's resolve config

      import { routesPresentation } from '@sanity/routes/plugin'

      presentationTool({
      resolve: routesPresentation('web'),
      })
      presentationTool({
      resolve: routesPresentation('web', {
      mainDocuments: [
      { route: '/blog/:slug', filter: '_type == "blogPost" && slug.current == $slug' },
      { route: '/docs/:slug', filter: '_type == "article" && slug.current == $slug' },
      ],
      extraLocations: {
      blogPost: (doc) => [
      { title: 'Blog index', href: '/blog' },
      ],
      },
      }),
      })