mirror of
https://github.com/linsa-io/linsa.git
synced 2026-02-23 10:54:55 +01:00
* wip * feat: new command palette * chore: add universal search * chore: cleanup * feat: use title class for heading * feat: add topic * chore: advance search
31 lines
742 B
TypeScript
31 lines
742 B
TypeScript
import { type ClassValue, clsx } from "clsx"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export const randomId = () => {
|
|
return Math.random().toString(36).substring(7)
|
|
}
|
|
|
|
export const toTitleCase = (str: string): string => {
|
|
return str
|
|
.replace(/([A-Z])/g, " $1")
|
|
.replace(/^./, str => str.toUpperCase())
|
|
.trim()
|
|
}
|
|
|
|
function escapeRegExp(string: string) {
|
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
}
|
|
|
|
export const searchSafeRegExp = (inputValue: string) => {
|
|
const escapedChars = inputValue.split("").map(escapeRegExp)
|
|
return new RegExp(escapedChars.join(".*"), "i")
|
|
}
|
|
|
|
export * from "./urls"
|
|
export * from "./slug"
|
|
export * from "./keyboard"
|