Skip to content

Commit

Permalink
feat: add slug function
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed Jun 8, 2024
1 parent dd16baf commit 295cf50
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/slug.ts
Original file line number Diff line number Diff line change
@@ -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,
});
};

0 comments on commit 295cf50

Please sign in to comment.