Files
afrov2/lib/utils.ts
streap2 d1e551bcca
All checks were successful
Build and Push App / build (push) Successful in 9m12s
feat: implement SEO enhancements, automatic slug generation, and font optimizations
2026-04-26 08:11:31 +02:00

14 lines
469 B
TypeScript

export function generateSlug(text: string): string {
return text
.toString()
.toLowerCase()
.trim()
.normalize('NFD') // remove accents
.replace(/[\u0300-\u036f]/g, '')
.replace(/\s+/g, '-') // replace spaces with -
.replace(/[^\w-]+/g, '') // remove all non-word chars
.replace(/--+/g, '-') // replace multiple - with single -
.replace(/^-+/, '') // trim - from start of text
.replace(/-+$/, ''); // trim - from end of text
}