Skip to content

Commit 8f3f49d

Browse files
authored
chore: run format (#142)
1 parent c26ed5a commit 8f3f49d

2 files changed

Lines changed: 35 additions & 18 deletions

File tree

‎src/tags/app-header/app-header.marko‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ script --
88

99
// Global Cmd+K shortcut
1010
script --
11-
document.addEventListener("keydown", (e: KeyboardEvent) => {
12-
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
13-
e.preventDefault();
14-
searchOpen = !searchOpen;
15-
}
16-
}, { signal: $signal });
11+
document.addEventListener(
12+
"keydown",
13+
(e: KeyboardEvent) => {
14+
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
15+
e.preventDefault();
16+
searchOpen = !searchOpen;
17+
}
18+
},
19+
{ signal: $signal },
20+
);
1721

1822
header#header
1923
a
@@ -52,7 +56,10 @@ header#header
5256
searchOpen = true;
5357
}
5458
kbd -- K
55-
html-script -- ${`document.currentScript.previousElementSibling.prepend(navigator.platform.startsWith("Mac")?"\u2318":"ctrl+")`}
59+
html-script --
60+
${
61+
`document.currentScript.previousElementSibling.prepend(navigator.platform.startsWith("Mac")?"\u2318":"ctrl+")`
62+
};
5663

5764
search-dialog open:=searchOpen
5865

‎src/tags/search-dialog/search-dialog.marko‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ static function highlightSegments(text: string, query: string) {
88
const escaped = q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
99
const parts = text.split(new RegExp(`(${escaped})`, "gi"));
1010
const lower = q.toLowerCase();
11-
return parts.filter(Boolean).map((p) => ({ text: p, hl: p.toLowerCase() === lower }));
11+
return parts
12+
.filter(Boolean)
13+
.map((p) => ({ text: p, hl: p.toLowerCase() === lower }));
1214
}
1315

1416
export interface Input {
@@ -18,7 +20,7 @@ export interface Input {
1820

1921
let/open:=input.open
2022
let/query=""
21-
let/results=undefined as SearchHit[] | undefined
23+
let/results=(undefined as SearchHit[] | undefined)
2224
let/activeIndex=-1
2325

2426
script --
@@ -55,10 +57,14 @@ dialog/$dialog
5557
,onKeyDown(e) {
5658
if (e.key === "ArrowDown") {
5759
e.preventDefault();
58-
if (results && results.length > 0) activeIndex = (activeIndex + 1) % results.length;
60+
if (results && results.length > 0) {
61+
activeIndex = (activeIndex + 1) % results.length;
62+
}
5963
} else if (e.key === "ArrowUp") {
6064
e.preventDefault();
61-
if (results && results.length > 0) activeIndex = (activeIndex - 1 + results.length) % results.length;
65+
if (results && results.length > 0) {
66+
activeIndex = (activeIndex - 1 + results.length) % results.length;
67+
}
6268
}
6369
}
6470
form
@@ -76,7 +82,7 @@ dialog/$dialog
7682
,type="text"
7783
,placeholder="Search docs..."
7884
,value:=query
79-
if=(results && results.length > 0)
85+
if=results && results.length > 0
8086
div class=styles.results
8187
for|result, i| of=results
8288
a/$el
@@ -99,14 +105,18 @@ dialog/$dialog
99105
if (i === activeIndex) {
100106
$el().scrollIntoView({ block: "nearest" });
101107
}
102-
const/titleMatch = query.trim() && result.title.toLowerCase().includes(query.trim().toLowerCase())
103-
const/displayText = titleMatch ? result.title : (result.snippet || result.title)
108+
const/titleMatch=(
109+
query.trim() &&
110+
result.title.toLowerCase().includes(query.trim().toLowerCase())
111+
)
112+
const/displayText=(
113+
titleMatch ? result.title : result.snippet || result.title
114+
)
104115
span class=styles.displayText
105116
for|seg| of=highlightSegments(displayText, query)
106-
if=(seg.hl)
117+
if=seg.hl
107118
mark class=styles.highlight -- ${seg.text}
108-
else
109-
-- ${seg.text}
119+
else -- ${seg.text}
110120
span class=styles.breadcrumbs -- ${result.breadcrumbs.join(" · ")}
111-
else if=(query.trim() && results)
121+
else if=query.trim() && results
112122
div class=styles.empty -- No results found.

0 commit comments

Comments
 (0)