From bbd2f56797b4d74b321348772d7b6dccf594b928 Mon Sep 17 00:00:00 2001 From: Jared Schoeny Date: Mon, 27 Oct 2025 20:07:48 -1000 Subject: [PATCH] Improve handling of accented letters with slugs --- src/app/submit/actions.ts | 5 +++++ src/components/Hack/HackSubmitForm.tsx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/app/submit/actions.ts b/src/app/submit/actions.ts index 7fe3bfd..fba2421 100644 --- a/src/app/submit/actions.ts +++ b/src/app/submit/actions.ts @@ -8,6 +8,11 @@ type HackInsert = TablesInsert<"hacks">; function slugify(text: string) { return text + .normalize("NFD") + .replace(/[\u0300-\u036f]/g, "") // strip combining diacritics + .replace(/ß/g, "ss") + .replace(/æ/g, "ae") + .replace(/œ/g, "oe") .toLowerCase() .trim() .replace(/[^a-z0-9]+/g, "-") diff --git a/src/components/Hack/HackSubmitForm.tsx b/src/components/Hack/HackSubmitForm.tsx index 16763d2..5294168 100644 --- a/src/components/Hack/HackSubmitForm.tsx +++ b/src/components/Hack/HackSubmitForm.tsx @@ -242,6 +242,11 @@ export default function HackSubmitForm({ dummy = false }: HackSubmitFormProps) { const slugify = (text: string) => text + .normalize("NFD") + .replace(/[\u0300-\u036f]/g, "") // strip combining diacritics + .replace(/ß/g, "ss") + .replace(/æ/g, "ae") + .replace(/œ/g, "oe") .toLowerCase() .trim() .replace(/[^a-z0-9]+/g, "-")