@@ -55,7 +55,14 @@ export default function Items ({ ssrData, variables = DEFAULT_VARIABLES, query,
55
55
< div className = { styles . grid } >
56
56
{ ad && < ListItem item = { ad } ad /> }
57
57
{ itemsWithPins . filter ( filter ) . map ( ( item , i ) => (
58
- < ListItem key = { `${ item . id } -${ i + 1 } ` } item = { item } rank = { rank && i + 1 } itemClassName = { variables . includeComments ? 'py-2' : '' } pinnable = { isHome ? false : pins ?. length > 0 } />
58
+ < ListItem
59
+ key = { `${ item . id } -${ i + 1 } ` }
60
+ item = { item }
61
+ rank = { rank && i + 1 }
62
+ itemClassName = { variables . includeComments ? 'py-2' : '' }
63
+ pinnable = { isHome ? false : pins ?. length > 0 }
64
+ isSearchResults = { Boolean ( variables . includeComments && variables . q ) }
65
+ />
59
66
) ) }
60
67
</ div >
61
68
< Foooter
@@ -67,16 +74,31 @@ export default function Items ({ ssrData, variables = DEFAULT_VARIABLES, query,
67
74
)
68
75
}
69
76
70
- export function ListItem ( { item, ...props } ) {
71
- return (
72
- item . parentId
73
- ? < CommentFlat item = { item } noReply includeParent { ...props } />
74
- : ( item . isJob
75
- ? < ItemJob item = { item } />
76
- : ( item . searchText
77
- ? < ItemFull item = { item } noReply { ...props } />
78
- : < Item item = { item } { ...props } /> ) )
79
- )
77
+ export function ListItem ( { item, isSearchResults, ...props } ) {
78
+ const searchClasses = isSearchResults
79
+ ? [
80
+ styles . searchResult ,
81
+ item . parentId ? styles . searchResultComment : styles . searchResultPost
82
+ ] . join ( ' ' )
83
+ : ''
84
+
85
+ const content = item . parentId
86
+ ? < CommentFlat item = { item } noReply includeParent { ...props } />
87
+ : ( item . isJob
88
+ ? < ItemJob item = { item } />
89
+ : ( item . searchText
90
+ ? < ItemFull item = { item } noReply { ...props } />
91
+ : < Item item = { item } { ...props } /> ) )
92
+
93
+ if ( isSearchResults ) {
94
+ return (
95
+ < div className = { searchClasses } >
96
+ { content }
97
+ </ div >
98
+ )
99
+ }
100
+
101
+ return content
80
102
}
81
103
82
104
export function ItemsSkeleton ( { rank, startRank = 0 , limit = LIMIT , Footer } ) {
0 commit comments