Created
September 9, 2023 09:49
-
-
Save guiseek/9b65dfb30cfa9e03cd4590599bdb7911 to your computer and use it in GitHub Desktop.
Slugify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const slugify = (...args: (string | number)[]): string => { | |
const value = args.join(' '); | |
return value | |
.normalize('NFD') | |
.replace(/[\u0300-\u036f]/g, '') | |
.toLowerCase() | |
.trim() | |
.replace(/[^a-z0-9 ]/g, '') | |
.replace(/\s+/g, '-'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment