Add a regenerate-slug button to the article editor - #201
Merged
Conversation
Rebuilds the slug from the current title. On a new article it just fills the slug box; on an existing one the regenerated slug is held as pending and only committed by an explicit save, so an article's public URL can never move under the 2.5s autosave. The editor redirects itself to the new /articles/<slug>/edit afterwards, since the route it was on no longer resolves. articles.slug carries no unique index, so two articles could otherwise land on one public URL: the button probes GET /v1/articles/<candidate> and falls back to -2, -3, ... up to -20 rather than reusing a slug that another article already holds. The pending state warns that the old /article/<slug> will 404 -- there is no redirect table, so nothing catches the old URL. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ssavutu
added a commit
that referenced
this pull request
Aug 7, 2026
Conflict was two tests added at the same point in the autosave describe block: this branch's "alt text autosaves on its own" and main's three regenerate-slug cases (#201). They test unrelated fields, so both are kept. editArticleView.tsx merged clean and correctly: the snapshot now carries both photoAlt and main's isNew-scoped slugInput, so an alt-text edit still autosaves and a regenerated slug still waits for an explicit save. Co-Authored-By: Claude Opus 5 <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.
Editors had no way to fix a slug after an article was created — the field was read-only and the slug was frozen at whatever the title happened to be on the first save.
What this adds
A Regenerate from title button under the Slug field in the article editor.
/articles/<slug>/edit, since the route it was on no longer resolves.articles.slughas no unique index (it isLONGTEXT), so the button probesGET /v1/articles/<candidate>and falls back to-2,-3, … up to-20rather than pointing two articles at one URL. The article's own slug counts as free.Server side needed no changes:
PATCH /v1/articles/{slug}already accepts and validates aslugfield.Known gap
There is no redirect table, so a regenerated slug leaves the old URL as a hard 404 rather than a 301. The pending-state hint warns about this and offers a "Keep the current slug" escape, but that is the only mitigation — worth a follow-up before this gets used much on published articles.
Supporting changes
slugifyCategory→slugify; it already matched the server'sCanonicalizeSlugrules exactly.<label>was split so the buttons underneath are not read out as part of the field's accessible name.Testing
Three tests added covering the autosave exclusion, the explicit-save path, and the
-2suffix. Full frontend suite passes (11 tests). Typecheck is clean apart from pre-existingTrixEditor.tsxerrors; lint shows only the pre-existingsaveArticledependency warning.🤖 Generated with Claude Code