chore: rename utils package to shared

This commit is contained in:
Henry
2025-01-29 16:21:30 +00:00
parent 8addf952a9
commit 34f8ad4def
26 changed files with 96 additions and 80 deletions

View File

@@ -0,0 +1,12 @@
export const colours: { name: string; code: string }[] = [
{ name: "Teal", code: "#0d9488" },
{ name: "Green", code: "#65a30d" },
{ name: "Blue", code: "#0284c7" },
{ name: "Purple", code: "#4f46e5" },
{ name: "Yellow", code: "#ca8a04" },
{ name: "Orange", code: "#ea580c" },
{ name: "Red", code: "#dc2626" },
{ name: "Pink", code: "#db2777" },
] as const;
export type Colour = (typeof colours)[number];

View File

@@ -0,0 +1 @@
export * from "./colours";

View File

@@ -0,0 +1,4 @@
export const name = "shared";
export * from "./constants";
export * from "./utils";

View 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
}

View 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();
}

View File

@@ -0,0 +1,2 @@
export * from "./generateUID";
export * from "./generateSlug";