Started working on the blogs

This commit is contained in:
cdricms
2025-02-21 17:49:42 +01:00
parent de828d4c13
commit 7a97961fef
9 changed files with 178 additions and 79 deletions

11
frontend/lib/sluggify.ts Normal file
View File

@@ -0,0 +1,11 @@
export default function sluggify(text: string): string {
return text
.toLowerCase() // Convert to lowercase
.trim() // Remove leading/trailing whitespace
.normalize("NFD") // Normalize special characters
.replace(/[\u0300-\u036f]/g, "") // Remove diacritics
.replace(/[^a-z0-9\s-]/g, "") // Remove special characters except spaces and hyphens
.replace(/\s+/g, "-") // Replace spaces with hyphens
.replace(/-+/g, "-") // Replace multiple hyphens with single hyphen
.slice(0, 100); // Limit length to 100 characters
}