Skip to content

Commit 39bb72c

Browse files
committed
update
1 parent 27be7f1 commit 39bb72c

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

src/bindings/DocSearch.res

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
// API: https://github.com/algolia/docsearch/tree/v3.3.0/packages/docsearch-react/src/types
2-
type contentType = [
3-
| #content
4-
| #lvl0
5-
| #lvl1
6-
| #lvl2
7-
| #lvl3
8-
| #lvl4
9-
| #lvl5
10-
| #lvl6
11-
]
1+
// API: https://github.com/algolia/docsearch/tree/v3.5.2/packages/docsearch-react/src/types
2+
type contentType =
3+
| @as("content") Content
4+
| @as("lvl0") Lvl0
5+
| @as("lvl1") Lvl1
6+
| @as("lvl2") Lvl2
7+
| @as("lvl3") Lvl3
8+
| @as("lvl4") Lvl4
9+
| @as("lvl5") Lvl5
10+
| @as("lvl6") Lvl6
1211

1312
type hierarchy = {
1413
lvl0: string,
15-
lvl1: Js.Nullable.t<string>,
14+
lvl1: string,
1615
lvl2: Js.Nullable.t<string>,
1716
lvl3: Js.Nullable.t<string>,
1817
lvl4: Js.Nullable.t<string>,
@@ -28,6 +27,8 @@ type docSearchHit = {
2827
@as("type") type_: contentType,
2928
anchor: Js.Nullable.t<string>,
3029
hierarchy: hierarchy,
30+
_highlightResult: {.},
31+
_snippetResult: {.},
3132
}
3233
type transformItems = array<docSearchHit>
3334

src/components/Search.res

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ let transformItems = (items: DocSearch.transformItems) => {
6565
| "/" => Url.Latest
6666
| other => Url.parse(other).version
6767
}
68-
6968
items->Belt.Array.keepMap(item => {
7069
// Transform absolute URL into relative
7170
let url = try Webapi.URL.make(item.url)->Some catch {
@@ -83,14 +82,8 @@ let transformItems = (items: DocSearch.transformItems) => {
8382
| Latest | NoVersion => "latest"
8483
| Version(v) => v
8584
}
86-
87-
if urlVersion == versionStr {
88-
let (lvl1, type_) = switch item.hierarchy.lvl1->Js.Nullable.toOption {
89-
| Some(_) => (item.hierarchy.lvl1, item.type_)
90-
| None => (item.hierarchy.lvl0->Js.Nullable.return, #lvl1)
91-
}
92-
let hierarchy = {...item.hierarchy, lvl1}
93-
{...item, url: pathname ++ hash, hierarchy, type_}->Some
85+
if urlVersion === versionStr {
86+
{...item, url: pathname ++ hash}->Some
9487
} else {
9588
None
9689
}
@@ -140,7 +133,6 @@ let make = () => {
140133
| "/" => focusSearch(e)
141134
| "k" if e.ctrlKey || e.metaKey => focusSearch(e)
142135
| "Escape" => handleCloseModal()
143-
// setState(_ => Inactive)
144136
| _ => ()
145137
}
146138
}
@@ -153,7 +145,6 @@ let make = () => {
153145
}
154146

155147
let onClose = React.useCallback(() => {
156-
// setState(_ => Inactive)
157148
handleCloseModal()
158149
}, [setState])
159150

0 commit comments

Comments
 (0)