Conversation
Implements Thinkmill#340 using the static, deterministic API proposed in the issue: collections can declare multiple slug fields that map onto the star segments of the collection path in order. collection({ path: 'src/content/blog/*/*', slugFields: ['locale', 'title'], slugField: 'title', schema: { locale: fields.text({ label: 'Locale' }), title: fields.slug({ name: { label: 'Title' } }) }, }) An entry with locale `en` and title slug `my-post` is stored at `src/content/blog/en/my-post`. The entry's slug is the segments joined with a slash (`en/my-post`), which keeps tree listing, routing, the reader and the GitHub/local storage backends deterministic - no callbacks or non-serialisable config. - fully backwards compatible: single `slugField` collections behave exactly as before - config validation: the number of star segments must match `slugFields.length`, every entry must be a slug field and the last entry must be the `slugField` - composite slug validation: secondary slug fields validate as slug segments while the primary field is checked for uniqueness against the full composite slug - covered by new unit tests in `slug-fields.test.ts`
tihu220
requested review from
BarnabyBishop,
JedWatson and
emmatown
as code owners
September 16, 2026 17:39
🦋 Changeset detectedLatest commit: 588447c The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
/claim #340 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #340
This implements the multi-slug API proposed by @JedWatson in the issue — keeping collection paths static and deterministic rather than resolving paths via a callback, so the on-disk location of entries is always known from config.
API
slugFieldsmaps onto a*segment ofpath, in order.en/my-post), so tree listing, routing, the reader and both storage backends work unchanged.slugFieldalone behave exactly as before.Behaviour notes
*segments must equalslugFields.length, every entry must be a slug-form field, and the last entry must be theslugField(the segment shown as "the slug" in the admin UI)...); the primary field is additionally checked for uniqueness against the composite slug, soen/my-postandfr/my-postcan co-exist while duplicate paths are still rejected.-copyto the primary segment.reader.collections.blog.read('en/my-post'), andlist()returns composite slugs.**glob collections are unaffected; combiningslugFieldswith**is a config error.Testing
packages/keystatic/src/app/slug-fields.test.tscover config validation, composite path mapping, slug computation, tree listing at exact depth (including ignoring too-deep entries) and readerlist/readfor both multi- and single-slug collections./claim #340