diff --git a/src/app/globals.css b/src/app/globals.css index 6af5aca7..d9c3e58e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -36,6 +36,10 @@ main :target { } } +mark { + @apply -m-[--pad] rounded-sm p-[--pad] [--pad:0.05rem]; +} + /** * Pmndrs theme for JavaScript, CSS and HTML * Loosely based on https://marketplace.visualstudio.com/items?itemName=pmndrs.pmndrs diff --git a/src/components/Search/SearchItem.tsx b/src/components/Search/SearchItem.tsx index cd8244e3..95cbe33a 100644 --- a/src/components/Search/SearchItem.tsx +++ b/src/components/Search/SearchItem.tsx @@ -30,9 +30,11 @@ function SearchItem({ className, search, result, + ...props }: Omit, 'href'> & SearchItemProps) { return ( ) => onSelect={router.push} className="rounded-md transition-colors data-[selected=true]:bg-surface-container-high" > - + ) })} diff --git a/src/utils/text.ts b/src/utils/text.ts index fda82168..20574f69 100644 --- a/src/utils/text.ts +++ b/src/utils/text.ts @@ -7,4 +7,6 @@ export const escape = (text: string) => text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$ * Bolds matching text, returning HTML. */ export const highlight = (text: string, target: string) => - text.replace(new RegExp(target, 'gi'), (match: string) => `${match}`) + target.length > 0 + ? text.replace(new RegExp(target, 'gi'), (match: string) => `${match}`) + : text