feat: add slug function

This commit is contained in:
Mauricio Siu
2024-06-08 16:41:46 -06:00
parent dd16baf234
commit 295cf50060

15
lib/slug.ts Normal file
View File

@@ -0,0 +1,15 @@
import slug from "slugify";
export const slugify = (text: string | undefined) => {
if (!text) {
return "";
}
const cleanedText = text.trim().replace(/[^a-zA-Z0-9\s]/g, "");
return slug(cleanedText, {
lower: true,
trim: true,
strict: true,
});
};