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:
Aslam
2024-09-06 16:22:48 +07:00
committed by GitHub
parent 2bebcbc20a
commit c3e99d1366
11 changed files with 548 additions and 181 deletions

View File

@@ -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"