Skip to content

Commit 25ba33d

Browse files
authored
[docs] Add docsearch integration (#1596)
* Add docsearch intergration * Pretty fixes
1 parent e2eba82 commit 25ba33d

File tree

4 files changed

+104
-7
lines changed

4 files changed

+104
-7
lines changed

docs/themes/htx/layout/layout.ejs

+13
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090

9191
<%- partial('partials/google_analytics') %>
9292

93+
<!-- docsearch -->
94+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
9395
</head>
9496
<body >
9597
<div id="mobile-bar" <%- isBlog ? 'style="display: none"' : '' %>>
@@ -134,5 +136,16 @@
134136
})
135137
});
136138
</script>
139+
140+
<!-- docsearch -->
141+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
142+
<script type="text/javascript"> docsearch({
143+
apiKey: 'e5286d9454e04e9d10c9e927b4a4a205',
144+
indexName: 'labelstud',
145+
inputSelector: '#docsearch-input',
146+
debug: false // Set debug to true if you want to inspect the dropdown
147+
});
148+
</script>
149+
137150
</body>
138151
</html>

docs/themes/htx/layout/partials/header.ejs

+8-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@
4949
</nav>
5050
</div>
5151
<a href="/playground" class="head-main-menu-item-link-single <%- page.type === "playground" ? "current": "" %>">Playground</a>
52-
<!-- <ul role="list" class="head-main-menu hidden w-list-unstyled"><li class="head-main-menu-item"><a href="/tags" class="head-main-menu-item-link">Tags</a></li><li class="head-main-menu-item"><a href="/templates" class="head-main-menu-item-link">Templates</a></li><li class="head-main-menu-item"><a href="/api" class="head-main-menu-item-link">API</a></li><li class="head-main-menu-item"><a href="/playground" class="head-main-menu-item-link">Playground</a></li><li class="head-main-menu-item"><a href="/blog" class="head-main-menu-item-link">Blog</a></li></ul> -->
52+
53+
<br><br>
54+
<div class="search__head">
55+
<input type="text" placeholder="Search" id="docsearch-input">
56+
<input type="submit" value="">
57+
</div>
58+
5359
</div>
5460

5561
<!-- <div class="head__menu--wrapper">
@@ -62,10 +68,7 @@
6268
<li class="<%- page.type === "blog" ? "current": "" %>"><a href="<%- url_for("/blog/") %>">Blog</a></li>
6369
</ul>
6470
</div> -->
65-
<!-- <div class="search__head">
66-
<input type="text" placeholder="Search" id="local-search-input">
67-
<input type="submit" value="">
68-
</div> -->
71+
6972
<!-- Place this tag where you want the button to render. -->
7073
<a class="github-button" href="https://github.com/heartexlabs/label-studio" data-size="large" data-show-count="true" aria-label="Star heartexlabs/label-studio on GitHub">GitHub</a>
7174
</div>

docs/themes/htx/source/css/_header.styl

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ body.docs
114114
&:focus
115115
border-color: $green
116116

117+
#docsearch-input
118+
padding: 4px 10px;
119+
border-radius: 4px;
120+
border: none;
121+
117122
#logo
118123
font-size: 1.5em
119124
line-height: $header-height

docs/themes/htx/source/css/new-header.css

+78-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
/* docsearch */
2+
.ds-dropdown-menu > * {
3+
line-height: normal;
4+
}
5+
6+
.ds-suggestion:hover {
7+
background: red !important;
8+
}
9+
10+
.algolia-docsearch-suggestion--wrapper {
11+
margin: 0 !important;
12+
padding: 0 !important;
13+
}
14+
15+
.algolia-docsearch-suggestion--category-header {
16+
font-weight: 500 !important;
17+
}
18+
19+
.algolia-docsearch-suggestion--subcategory-column {
20+
display: none !important;
21+
}
22+
23+
.algolia-docsearch-suggestion--content {
24+
width: 100% !important;
25+
border: none !important;
26+
box-shadow: none !important;
27+
outline: none !important;
28+
}
29+
.algolia-docsearch-suggestion--content:before {
30+
display: none !important;
31+
}
32+
.algolia-docsearch-suggestion--title {
33+
font-weight: 400 !important;
34+
}
35+
36+
.algolia-docsearch-suggestion--highlight {
37+
color: #f58a48 !important;
38+
}
39+
40+
.ds-dataset-1 {
41+
42+
}
43+
44+
.ds-suggestions {
45+
46+
}
47+
48+
.ds-suggestion {
49+
50+
}
51+
52+
.algolia-docsearch-footer {
53+
display: none !important;
54+
}
55+
56+
157
div.container__head{
258
padding-left:40px;
359
padding-right:40px;
@@ -32,6 +88,7 @@ div.container__head{
3288
display: flex;
3389
align-items:center;
3490
padding:0px;
91+
margin: 0 10px;
3592
list-style-type: none;
3693
}
3794
.head__main>.container__head>.head__menu--wrapper > *{
@@ -134,11 +191,11 @@ div.container__head{
134191
justify-content:center;
135192
position: relative;
136193
}
137-
.head__main .search__head>input[type="text"]{
194+
#docsearch-input, .head__main .search__head>input[type="text"]{
138195
box-sizing: border-box;
139196
width: 180px;
140197
height:40px;
141-
background: rgba(0, 0, 0, 0.05);
198+
background: rgba(5, 0, 0, 0.05);
142199
border-radius: 6px;
143200
outline:none;
144201
border:0px;
@@ -147,6 +204,11 @@ div.container__head{
147204
font-size:18px;
148205
font-weight:500;
149206
color:#000;
207+
transition: all 0.25s;
208+
}
209+
#docsearch-input:focus {
210+
background-color: rgba(255, 255, 255, 0.9);
211+
width: 300px;
150212
}
151213
.head__main .search__head>input[type="submit"]{
152214
position: absolute;
@@ -162,6 +224,12 @@ div.container__head{
162224
cursor:pointer;
163225
right: 12px;
164226
}
227+
@media (max-width: 991px) {
228+
.head__main .search__head>input[type="submit"] {
229+
display: none;
230+
}
231+
232+
}
165233

166234
.head__main .search__head>input[type="text"]::-webkit-input-placeholder { /* Chrome/Opera/Safari */
167235
color: rgba(0,0,0,.2);
@@ -202,6 +270,10 @@ div.container__head{
202270
}
203271
}
204272
@media (max-width: 991px){
273+
div.container__head{
274+
padding: 0;
275+
}
276+
205277
.small__head{
206278
display: flex;
207279
justify-content: space-between;
@@ -302,4 +374,8 @@ div.container__head{
302374
.head__main{
303375
min-height:60px;
304376
}
377+
378+
#docsearch-input {
379+
display: none;
380+
}
305381
}

0 commit comments

Comments
 (0)