mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-03-21 17:54:09 -05:00
Improve handling of accented letters with slugs
This commit is contained in:
parent
9681bd97a7
commit
bbd2f56797
|
|
@ -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, "-")
|
||||
|
|
|
|||
|
|
@ -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, "-")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user