Improve event slug generation: include date, number duplicates#1123
Merged
Conversation
Cover formatSlug/formatDateForSlug helpers and the ensureUniqueSlug hook: auto-generation from title + date, numbered duplicate suffixes, collision errors, and current-doc/tenant scoping of the uniqueness check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Preview deployment: https://featximprove-slug-field.preview.avy-fx.org |
Custom Field components replace Payload's default rendering, so admin.description was never shown — render it via FieldDescription. Add an Events collection e2e test asserting the description renders and the regenerate button builds the slug from title + start date in the real admin, plus a unit test pinning the description strings slugField() produces. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Description
Improves auto-generated slugs for collections with many same-named documents (notably events — ~150 share the title "Avalanche Awareness Class"). Slugs now reliably include the start date and resolve duplicates with a numbered suffix, and the admin UI's regenerate button matches the server behavior. Also fixes a bug where the date never made it into the slug if an editor touched the slug field.
Related Issues
Key Changes
SlugComponent): it composestitle + -YYYY-MM-DDinstead of title-only. Previously the date logic only ran when the slug was left blank, so clicking ↻ (or otherwise populating the field) silently dropped the date.formatDateForSlugmoved toformatSlug.tsso the client component and server hook share one definition.-copyfor auto-generating fields: on the Payload "Duplicate" action the slug copies verbatim andensureUniqueSlugbumps it to-2,-3, … (matching the field description). Manual-slug collections keep-copy.formatSlug/formatDateForSlugand theensureUniqueSlughook (auto-generation, numbered suffixes, collision errors, current-doc + tenant scoping).How to test
…-YYYY-MM-DD.-2(not-copy).pnpm test,pnpm tsc,pnpm lintall pass.Screenshots / Demo video
Migration Explanation
No schema change — slug generation is hook/UI logic only. No migration required.
Future enhancements / Questions
-copyon duplicate; happy to extend numbered suffixes to them too if preferred.rei-…) if event titles stay generic.