Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bindings/DocSearch.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type contentType =
| @as("lvl6") Lvl6

type hierarchy = {
lvl0: string,
lvl1: string,
lvl0: Nullable.t<string>,
lvl1: Nullable.t<string>,
lvl2: Nullable.t<string>,
lvl3: Nullable.t<string>,
lvl4: Nullable.t<string>,
Expand Down
26 changes: 19 additions & 7 deletions src/components/Search.res
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,25 @@ let transformItems = (items: DocSearch.transformItems) => {
| Some({pathname, hash}) =>
RegExp.test(/v(8|9|10|11)\./, pathname)
? None
: Some({
...item,
deprecated: pathname->String.includes("api/js") || pathname->String.includes("api/core")
? Some("Deprecated")
: None,
url: pathname->String.replace("/v12.0.0/", "/") ++ hash,
})
: {
// DocSearch internally calls .replace() on hierarchy.lvl1, so we must
// provide a fallback for items where lvl1 is null to prevent crashes
let hierarchy = item.hierarchy
let lvl0 = hierarchy.lvl0->Nullable.toOption->Option.getOr("")
let lvl1 = hierarchy.lvl1->Nullable.toOption->Option.getOr(lvl0)
Some({
...item,
deprecated: pathname->String.includes("api/js") || pathname->String.includes("api/core")
? Some("Deprecated")
: None,
url: pathname->String.replace("/v12.0.0/", "/") ++ hash,
hierarchy: {
...hierarchy,
lvl0: Nullable.make(lvl0),
lvl1: Nullable.make(lvl1),
},
})
}
| None => None
}
})
Expand Down