mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-04-23 01:01:28 +00:00
9 lines
333 B
JavaScript
9 lines
333 B
JavaScript
export const highlightText = (text, query) => {
|
|
if (!query) return text;
|
|
const parts = text.split(new RegExp(`(${query})`, 'gi'));
|
|
return parts.map((part, index) =>
|
|
part.toLowerCase() === query.toLowerCase()
|
|
? <span key={index} className="text-yellow-300">{part}</span>
|
|
: part
|
|
);
|
|
}; |