This project demonstrates advanced Sanity Studio patterns and custom input components. Currently focused on the Async URL Slug Preview feature, with recursive taxonomy examples coming soon.
Pattern: Custom input component with dynamic URL prefix generation
A custom Sanity input component that shows a live URL preview with an asynchronously generated prefix. The prefix updates automatically based on document fields (like language, category, etc.).
Use case: Internationalized content, dynamic URL structures, SEO-friendly URLs
Features:
- Live URL preview with prefix (e.g.,
en-US/articles/my-slug) - Async prefix generation based on document fields
- Loading states during prefix resolution
- Auto-slug generation from title
- Full URL tracking for frontend routing
Files:
schemas/article.ts- Example document using the featureschemas/objects/urlSlug.ts- Custom urlSlug object typelib/components/AsyncUrlSlugInput/- React component and hooklib/helpers/slugGeneration.ts- Core logic for prefix resolutionlib/constants/urlPrefixes.ts- URL prefix configuration
Documentation:
- ASYNC_URL_SLUG.md - Complete async URL slug feature guide
- PUBLISHING_METADATA.md - Fieldsets and groups explained
- Node.js 18+
- pnpm
pnpm install- Create a Sanity project at sanity.io/manage
- Update
sanity.config.tsandsanity.cli.tswith your project ID - Run the development server:
pnpm devpnpm typegen- Sanity V5
- TypeScript
- pnpm
- React (for custom components)
This project will include three different approaches to building recursive/hierarchical document structures in Sanity Studio V5:
| Pattern | Description | Use Case | Complexity |
|---|---|---|---|
| Cars | Self-referencing documents with parent field |
Hierarchical categories, nested pages | High |
| Bikes | Settings-based navigation with nested arrays | Menu-driven navigation, editor-defined structure | High |
| Clothing | Simple category filter using .child() |
Product catalogs, category → items | Low |
These examples will demonstrate different approaches to recursive structures using the Structure Builder API and RxJS observables.
MIT