Extract search option as a Vue component (#838)

This commit is contained in:
Chenlei Hu
2024-09-15 17:15:19 +09:00
committed by GitHub
parent 7025e321de
commit 7d25d976d1
3 changed files with 80 additions and 69 deletions

View File

@@ -33,3 +33,9 @@ export function appendJsonExt(path: string) {
export function trimJsonExt(path: string) {
return path.replace(/\.json$/, '')
}
export function highlightQuery(text: string, query: string) {
if (!query) return text
const regex = new RegExp(`(${query})`, 'gi')
return text.replace(regex, '<span class="highlight">$1</span>')
}