File tree Expand file tree Collapse file tree 2 files changed +42
-14
lines changed Expand file tree Collapse file tree 2 files changed +42
-14
lines changed Original file line number Diff line number Diff line change @@ -3,24 +3,34 @@ export function searchResults({ query, results }) {
3
3
4
4
if ( ! results ) return "" ;
5
5
6
- const resultsHTML = results ? results
7
- . filter ( Boolean )
8
- . map ( ( [ method , path , operation ] ) => {
9
- const route = `${ method } ${ path } ` . replace ( queryRegex , `<mark>$1</mark>` ) ;
10
- const summary = operation . summary . replace ( queryRegex , `<mark>$1</mark>` ) ;
11
- return `<article>
6
+ const resultsHTML = results
7
+ ? results
8
+ . filter ( Boolean )
9
+ . map ( ( [ method , path , operation ] ) => {
10
+ const route = `${ method } ${ path } ` . replace (
11
+ queryRegex ,
12
+ `<mark>$1</mark>`
13
+ ) ;
14
+ const summary = operation . summary . replace (
15
+ queryRegex ,
16
+ `<mark>$1</mark>`
17
+ ) ;
18
+ return `<li>
12
19
<a href="/${ method } /${ path } ">
13
- ${ summary }
14
- (< code>${ route } </code>)
20
+ <h3> ${ summary } </h3>
21
+ <pre>< code>${ route } </code></pre>
15
22
</a>
16
- </article>` ;
17
- } )
18
- . join ( "\n" ) : "" ;
23
+ </li>` ;
24
+ } )
25
+ . join ( "\n" )
26
+ : "" ;
19
27
20
28
if ( resultsHTML ) {
21
- return `<h2>Results</h2>
29
+ return `<h2>${ results . length } Results</h2>
22
30
23
- ${ resultsHTML } ` ;
31
+ <ul>
32
+ ${ resultsHTML }
33
+ </ul>` ;
24
34
}
25
35
26
36
if ( query ) {
Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ button {
41
41
padding : 0.375em 0.75em ;
42
42
}
43
43
44
-
45
44
label .has-placeholder > span ,
46
45
label .has-placeholder > br {
47
46
/* @hidden-accessible */
@@ -154,6 +153,25 @@ form h1 {
154
153
margin-left : calc (-0.75em - 1px );
155
154
}
156
155
156
+ /* Search results */
157
+ .results ul {
158
+ list-style : none;
159
+ padding : 0 ;
160
+ }
161
+ .results li a {
162
+ display : block;
163
+ padding : 1em ;
164
+ margin : 0 -1em ;
165
+
166
+ text-decoration : none;
167
+ }
168
+ .results li a : hover {
169
+ background : # ffc ;
170
+ }
171
+ .results li a > * {
172
+ margin : 0 ;
173
+ }
174
+
157
175
/* Details */
158
176
.details {
159
177
margin-left : -1.5rem ;
You can’t perform that action at this time.
0 commit comments