···
37
37
for (let i = 0; i < search.results.length && i < 5; i++) {
38
38
let result = await search.results[i].data();
39
39
40
40
-
let excerpt = result.excerpt;
41
41
-
// replace <mark> tags with <span class="bg-pink-600/10">
42
42
-
excerpt = excerpt.replaceAll(
43
43
-
"<mark>",
44
44
-
'<span class="bg-accent-500/20 rounded-md p-0.5">'
45
45
-
);
46
46
-
excerpt = excerpt.replaceAll("</mark>", "</span>");
47
47
-
48
48
-
newResults[i] = {
49
49
-
title: result.meta.title,
50
50
-
content: excerpt,
51
51
-
href: result.url,
52
52
-
};
40
40
+
for(let j = 0; j < result.sub_results.length; j++) {
41
41
+
newResults.push({
42
42
+
title: result.sub_results[j].title,
43
43
+
content: result.meta.title,
44
44
+
href: result.sub_results[j].url,
45
45
+
});
46
46
+
}
53
47
}
54
48
55
55
-
results = Object.values(newResults);
49
49
+
results = newResults.slice(0, 5);
56
50
};
57
51
58
52
export let value: string = "";
···
146
140
currentSelection < results.length
147
141
) {
148
142
window.location.href = results[currentSelection].href;
149
149
-
} else {
150
150
-
$showSearch = false;
151
143
}
144
144
+
$showSearch = false;
152
145
}
153
146
154
147
// on arrow down
···
206
199
<!-- Active: "bg-indigo-600 text-white" -->
207
200
{#each results as result, i}
208
201
<a
202
202
+
on:click={() => {
203
203
+
$showSearch = false;
204
204
+
}}
209
205
href={result.href}
210
206
class="w-full {currentSelection === i
211
207
? 'bg-white/5'