Allow renaming shortcodes

Shortcodes can now be changed via PATCH /pages/:id with the same
validation as on create (format, collisions, reserved root codes,
usernames). Stats, link buttons and the homepage pin follow the page.

The settings tab shows a warning while editing and asks for
confirmation, since the old URL stops working immediately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 16:02:52 +02:00
co-authored by Claude Opus 5.5
parent 3929ed7663
commit 90cc10de10
6 changed files with 131 additions and 13 deletions
+3
View File
@@ -106,6 +106,9 @@ export function updatePage(db: Db, actor: Actor, id: number, input: UpdatePageIn
if ((input.title !== undefined || input.theme !== undefined) && page.kind !== "linkpage") {
throw new HttpError(400, "Only link pages have a title and theme");
}
if (input.code !== undefined && input.code !== page.code && codeTaken(db, page.namespace, input.code)) {
throw new HttpError(409, "Shortcode is not available", { code: ["Already in use or reserved"] });
}
db.update(pages)
.set({ ...input, updatedAt: new Date() })
.where(eq(pages.id, id))