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 }