NOW MANAGED ON CODEBERG
Added name highlighting in search results
Dan Brownab4e99bb187f
diff --git a/app/Entities/Tools/SearchResultsFormatter.php b/app/Entities/Tools/SearchResultsFormatter.phpindex aaa5c129d..24dc820a4 100644--- a/app/Entities/Tools/SearchResultsFormatter.php+++ b/app/Entities/Tools/SearchResultsFormatter.php@@ -30,11 +30,17 @@ class SearchResultsFormatter$textContent = $entity->$textProperty;$terms = array_merge($options->exacts, $options->searches);- $matchRefs = $this->getMatchPositions($textContent, $terms);- $mergedRefs = $this->sortAndMergeMatchPositions($matchRefs);- $content = $this->formatTextUsingMatchPositions($mergedRefs, $textContent);-- $entity->setAttribute('preview_content', new HtmlString($content));+ $originalContentByNewAttribute = [+ 'preview_name' => $entity->name,+ 'preview_content' => $textContent,+ ];++ foreach ($originalContentByNewAttribute as $attributeName => $content) {+ $matchRefs = $this->getMatchPositions($content, $terms);+ $mergedRefs = $this->sortAndMergeMatchPositions($matchRefs);+ $formatted = $this->formatTextUsingMatchPositions($mergedRefs, $content);+ $entity->setAttribute($attributeName, new HtmlString($formatted));+ }}/**diff --git a/resources/views/entities/list-item-basic.blade.php b/resources/views/entities/list-item-basic.blade.phpindex 2ec4bee5c..398c33b93 100644--- a/resources/views/entities/list-item-basic.blade.php+++ b/resources/views/entities/list-item-basic.blade.php@@ -2,7 +2,7 @@<a href="{{ $entity->getUrl() }}" class="{{$type}} {{$type === 'page' && $entity->draft ? 'draft' : ''}} {{$classes ?? ''}} entity-list-item" data-entity-type="{{$type}}" data-entity-id="{{$entity->id}}"><span role="presentation" class="icon text-{{$type}}">@icon($type)</span><div class="content">- <h4 class="entity-list-item-name break-text">{{ $entity->name }}</h4>+ <h4 class="entity-list-item-name break-text">{{ $entity->preview_name ?? $entity->name }}</h4>{{ $slot ?? '' }}</div></a>\ No newline at end of file