Skip to content

Commit

Permalink
make highlighting case insensitive ('demo' highlights 'DEmo')
Browse files Browse the repository at this point in the history
  • Loading branch information
Herbert Maschke committed Jul 5, 2022
1 parent 3826f65 commit 30d00e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Http/Livewire/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ private function highlightSearchResults(Collection $posts, ?string $search = nul
return $posts;
}

$class = config('zeus-sky.search_result_highlight_css_class', 'highlight');

foreach ($posts as $i => $post) {
$posts[$i]->content = strtr($post->content, [
$search => sprintf(
'<span class="%s">%s</span>',
config('zeus-sky.search_result_highlight_css_class', 'highlight'),
$search
),
]);
$posts[$i]->content = str_ireplace(
$search,
sprintf('<span class="%s">%s</span>', $class, $search),
$post->content,
);
}

return $posts;
Expand Down

0 comments on commit 30d00e3

Please sign in to comment.