chore: rename utils package to shared
This commit is contained in:
8
packages/shared/src/utils/generateSlug.ts
Normal file
8
packages/shared/src/utils/generateSlug.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export function generateSlug(text: string): string {
|
||||
return text
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^\w\s-]/g, "") // Remove special characters
|
||||
.replace(/\s+/g, "-") // Replace spaces with hyphens
|
||||
.replace(/-+/g, "-"); // Remove consecutive hyphens
|
||||
}
|
||||
10
packages/shared/src/utils/generateUID.ts
Normal file
10
packages/shared/src/utils/generateUID.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { customAlphabet } from "nanoid";
|
||||
|
||||
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
const length = 12;
|
||||
|
||||
const nanoid = customAlphabet(alphabet, length);
|
||||
|
||||
export function generateUID() {
|
||||
return nanoid();
|
||||
}
|
||||
2
packages/shared/src/utils/index.ts
Normal file
2
packages/shared/src/utils/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./generateUID";
|
||||
export * from "./generateSlug";
|
||||
Reference in New Issue
Block a user