Skip to content

Commit fa9ff78

Browse files
committed
update
1 parent 5b7c22e commit fa9ff78

File tree

7 files changed

+518
-345
lines changed

7 files changed

+518
-345
lines changed

package-lock.json

Lines changed: 468 additions & 320 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
},
1717
"dependencies": {
18-
"@docsearch/react": "^3.3.0",
18+
"@docsearch/react": "^3.5.2",
1919
"@headlessui/react": "^1.2.0",
2020
"@mdx-js/loader": "^2.3.0",
2121
"@rescript/react": "^0.10.3",

pages/_document.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ const isProduction = process.env.ENV === "production";
66
export default function Document() {
77
return (
88
<Html>
9-
<Head>
10-
<link
11-
rel="stylesheet"
12-
href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
13-
/>
14-
<script
15-
type="text/javascript"
16-
src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"
17-
/>
18-
</Head>
9+
<Head />
1910
<body>
2011
<Main />
2112
<NextScript />

src/bindings/DocSearch.res

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ type contentType = [
1111
]
1212

1313
type hierarchy = {
14-
"lvl0": string,
15-
"lvl1": string,
16-
"lvl2": Js.Nullable.t<string>,
17-
"lvl3": Js.Nullable.t<string>,
18-
"lvl4": Js.Nullable.t<string>,
19-
"lvl5": Js.Nullable.t<string>,
20-
"lvl6": Js.Nullable.t<string>,
14+
lvl0: string,
15+
lvl1: string,
16+
lvl2: Js.Nullable.t<string>,
17+
lvl3: Js.Nullable.t<string>,
18+
lvl4: Js.Nullable.t<string>,
19+
lvl5: Js.Nullable.t<string>,
20+
lvl6: Js.Nullable.t<string>,
2121
}
2222

2323
type docSearchHit = {

src/components/Navigation.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ module MobileNav = {
372372
let extLink = "block hover:cursor-pointer hover:text-white text-gray-60"
373373
<div className="border-gray-80 border-t">
374374
<ul>
375-
<li className=base>
376-
<DocSearch.Textbox id="docsearch-mobile" />
377-
</li>
375+
// <li className=base>
376+
// <DocSearch.Textbox id="docsearch-mobile" />
377+
// </li>
378378
<li className=base>
379379
<Link href="/try" className={linkOrActiveLink(~target="/try", ~route)}>
380380
{React.string("Playground")}

src/components/Search.res

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ let make = () => {
7979
onClose
8080
initialScrollY={window->scrollY}
8181
transformItems={items => {
82+
// Js.log(items)
8283
// Transform absolute URL intro relative url
8384
items->Js.Array2.map(item => {
8485
let url = try Util.Url.make(item.url).pathname catch {
@@ -94,13 +95,45 @@ let make = () => {
9495
let (content, type_) = switch item.content->Js.Nullable.toOption {
9596
| Some(c) => (c->Js.Nullable.return, item.type_)
9697
| None =>
97-
let fallback = item.hierarchy["lvl0"]
98+
let fallback = item.hierarchy.lvl0
9899
(fallback->Js.Nullable.return, #content)
99100
}
100101

101102
{...item, url, content, type_}
102103
})
103104
}}
105+
hitComponent={({hit, children}) => {
106+
let description = switch hit.url
107+
->Js.String2.split("/")
108+
->Js.Array2.sliceFrom(1)
109+
->Belt.List.fromArray {
110+
| list{"blog", ..._} => "BLOG"
111+
| list{"docs", "manual", version, ...rest} =>
112+
let path = rest->Belt.List.toArray
113+
114+
let info =
115+
path
116+
->Js.Array2.slice(~start=0, ~end_=Js.Array2.length(path) - 1)
117+
->Js.Array2.map(Js.String2.toUpperCase)
118+
119+
let version = if version == "latest" {
120+
"Latest"
121+
} else {
122+
version
123+
}
124+
125+
[version]->Js.Array2.concat(info)->Js.Array2.joinWith(" / ")
126+
| _ => ""
127+
}
128+
// <div className="flex flex-col w-full">
129+
<a href={hit.url} className="flex flex-col w-full">
130+
<span className="text-gray-60 captions px-4 py-2 block">
131+
{description->React.string}
132+
</span>
133+
children
134+
</a>
135+
// </div>
136+
}}
104137
/>,
105138
element,
106139
)

styles/_docsearch.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@
166166
}
167167

168168
.DocSearch-Hit {
169-
border-radius: 4px;
170-
@apply relative flex;
169+
/* border-radius: 4px; */
170+
@apply relative flex rounded-s border-b border-gray-20;
171171
}
172172

173173
.DocSearch-Hit a {
@@ -201,10 +201,11 @@
201201
}
202202

203203
.DocSearch-Hit-Container {
204-
@apply flex items-center flex-row p-4 text-gray-40;
204+
@apply flex items-center flex-row px-4 pb-4 pt-1 text-gray-40;
205205
}
206206

207207
.DocSearch-Hit-icon {
208+
/* display: none; */
208209
@apply w-5 h-5 stroke-1 text-gray-40;
209210
}
210211

0 commit comments

Comments
 (0)