mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
feat: command palette (#140)
* wip * feat: new command palette * chore: add universal search * chore: cleanup * feat: use title class for heading * feat: add topic * chore: advance search
This commit is contained in:
@@ -9,6 +9,22 @@ 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"
|
||||
|
||||
Reference in New Issue
Block a user