File tree Expand file tree Collapse file tree 4 files changed +22
-10
lines changed Expand file tree Collapse file tree 4 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 88
99class DocTransformer implements DocumentTransformer
1010{
11+ private function normalizeConent ($ value )
12+ {
13+ return str ($ value )
14+ ->lower ()
15+ ->explode (' ' )
16+ ->map (fn ($ word ) => Str::singular ($ word ))
17+ ->join (' ' );
18+ }
19+
1120 public function handle (DocumentFragment $ fragment , $ entry ): void
1221 {
22+ $ fragment ->additionalContextData [] = $ this ->normalizeConent ($ entry ->title );
23+
1324 // Add some extra details to "additional_context"
1425 if (Str::containsAll ($ fragment ->content , ['clear ' , 'cache ' ])) {
1526 $ fragment ->additionalContextData [] = 'delete cache ' ;
Original file line number Diff line number Diff line change @@ -88,6 +88,11 @@ public function handle(SearchEntriesCreated $event): void
8888
8989 $ data ['url ' ] = $ data ['search_url ' ];
9090
91+ // Clear this out to prevent "too much" from a specific page dominating the results.
92+ if (! $ data ['is_root ' ]) {
93+ $ data ['origin_title ' ] = null ;
94+ }
95+
9196 $ section ->searchEntry ->data ($ data );
9297 }
9398 }
Original file line number Diff line number Diff line change 3232 'title ' ,
3333 'search_title ' ,
3434 'content ' ,
35+ 'origin_title ' ,
3536 'search_content ' ,
3637 'additional_context ' ,
3738 'hierarchy_lvl0 ' ,
4546 'proximity ' ,
4647 'attribute ' ,
4748 'exactness ' ,
49+ 'origin_title:desc ' ,
4850 'hierarchy_lvl0:asc ' ,
4951 ],
5052 'searchableAttributes ' => [
53+ 'additional_context ' ,
54+ 'hierarchy_lvl0 ' ,
5155 'title ' ,
56+ 'origin_title ' ,
5257 'search_title ' ,
53- 'content ' ,
5458 'search_content ' ,
55- 'additional_context ' ,
56- 'hierarchy_lvl0 ' ,
5759 'hierarchy_lvl1 ' ,
5860 'url ' ,
5961 ],
Original file line number Diff line number Diff line change 11 <div x-data =" { tab: '{{ active }}' }" x-cloak class =" mt-2" >
22 <div class =" relative" >
3- {{#
4- Don't add tab names to search results. They just clutter it up.
5- Note: this only works when using the `/documentation-search` views.
6- #}}
7- {{ unless is_rendering_search }}
8- <div class =" flex space-x bg-[#292D3E] rounded-t-lg inline-flex" >
3+ <div class =" flex space-x bg-[#292D3E] rounded-t-lg inline-flex" data-indexer =" ignore" >
94 {{ foreach :tabs }}
105 <button type =" button" class =" text-sm bg-black text-gray-dark hover:text-gray-light pt-1.5 pb-1 px-3 rounded-t-md" x-on:click =" tab = '{{ key }}'" :class =" { 'bg-[#292D3E] text-gray-light': tab === '{{ key }}' }" >{{ value }}</button >
116 {{ /foreach :tabs }}
127 </div >
13- {{ /unless }}
148 {{ foreach :samples }}
159 <div class =" tab-content" x-show =" tab === '{{ key }}'" >{{ value }}</div >
1610 {{ /foreach :samples }}
You can’t perform that action at this time.
0 commit comments