Skip to content

Commit 5420dd2

Browse files
feat: integrate algolia v3
1 parent 8b5822f commit 5420dd2

File tree

7 files changed

+71
-16
lines changed

7 files changed

+71
-16
lines changed

src/app/homepage/header/header.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
<ng-content></ng-content>
4646
<app-social-wrapper></app-social-wrapper>
4747
<div class="menu-wrapper">
48-
<div class="search-wrapper">
48+
<div class="search-wrapper" id="search">
4949
<i class="fa fa-search search-icon"></i>
50-
<input id="search" class="search-input" placeholder="Search..." />
50+
<input class="search-input" placeholder="Search..." />
5151
</div>
5252
<ul>
5353
<li>

src/app/homepage/header/header.component.scss

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,23 @@ header {
359359
position: relative;
360360
}
361361

362-
.search-icon {
362+
.search-icon,
363+
:host ::ng-deep .DocSearch-Search-Icon {
363364
position: absolute;
364365
margin-top: 7px;
365-
color: #a5a5a5;
366+
color: #a5a5a5 !important;
366367
font-size: 14px;
368+
width: 14px;
369+
}
370+
371+
:host ::ng-deep .DocSearch-Search-Icon {
372+
@media (max-width: 1150px) {
373+
margin-top: 0;
374+
}
367375
}
368376

369-
.search-input {
377+
.search-input,
378+
::ng-deep .DocSearch-Button {
370379
background: transparent;
371380
border: 0;
372381
border-bottom: 2px solid #414141;
@@ -377,7 +386,7 @@ header {
377386
font-size: 14px;
378387
outline: 0 !important;
379388
transition: all 90ms ease-in-out;
380-
width: 165px;
389+
width: 215px;
381390

382391
&:active,
383392
&:focus {
@@ -386,11 +395,45 @@ header {
386395
}
387396
}
388397

398+
::ng-deep .DocSearch-Button:hover,
399+
::ng-deep .DocSearch-Button:active
400+
::ng-deep .DocSearch-Button:focus {
401+
border-bottom-color: $red-color;
402+
width: 240px;
403+
}
404+
389405
.search-input::placeholder {
390406
color: #a5a5a5;
391407
opacity: 1;
392408
}
393409

410+
::ng-deep .DocSearch-Button {
411+
border-radius: 0;
412+
color: #a5a5a5;
413+
padding: 5px;
414+
}
415+
416+
::ng-deep .DocSearch-Button-Placeholder {
417+
padding-left: 30px;
418+
font-size: 14px;
419+
margin-top: 7px;
420+
display: block !important;
421+
422+
@media (max-width: 1150px) {
423+
margin-top: 0;
424+
}
425+
}
426+
427+
::ng-deep .DocSearch-Button-Keys {
428+
display: none;
429+
}
430+
431+
::ng-deep .DocSearch-Button:active,
432+
::ng-deep .DocSearch-Button:focus,
433+
::ng-deep.DocSearch-Button:hover {
434+
color: #a5a5a5;
435+
}
436+
394437
.close-icon {
395438
position: absolute;
396439
right: 0;

src/app/homepage/homepage.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ export class HomepageComponent implements OnInit, OnDestroy, AfterViewInit {
157157
createDocSearchScriptTag(): HTMLScriptElement {
158158
const scriptTag = document.createElement('script');
159159
scriptTag.type = 'text/javascript';
160-
scriptTag.src =
161-
'https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js';
160+
scriptTag.src = 'https://cdn.jsdelivr.net/npm/@docsearch/js@3';
162161
scriptTag.async = true;
163162
scriptTag.onload = () => {
164163
(window as any).docsearch({
165164
apiKey: environment.algoliaApiKey,
166165
indexName: 'nestjs',
167-
inputSelector: '#search',
166+
container: '#search',
167+
appId: 'SDCBYAN96J',
168168
debug: false,
169169
});
170170
};

src/environments/environment.prod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const environment = {
22
production: true,
3-
algoliaApiKey: '9ea53de1a6911255834352bbbe4d3417'
3+
algoliaApiKey: '6d1869890dab96592b191e63a8deb5b5',
44
};

src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const environment = {
22
production: false,
3-
algoliaApiKey: '9ea53de1a6911255834352bbbe4d3417'
3+
algoliaApiKey: '6d1869890dab96592b191e63a8deb5b5'
44
};

src/index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@
7272
></script>
7373
<link href="https://cdn.carbonads.com" rel="preconnect" crossorigin>
7474
<link href="https://cdn.jsdelivr.net" rel="preconnect" crossorigin>
75-
<link
76-
rel="stylesheet"
77-
href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
78-
/>
75+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" />
7976

8077
<script>
8178
(function(i, s, o, g, r, a, m) {

src/styles.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
@import './scss/utils.scss';
66

77
:root {
8-
// scroll-behavior: smooth;
8+
--docsearch-primary-color: #ed2945;
9+
--docsearch-highlight-color: #ed2945;
10+
--docsearch-logo-color: #ed2945;
11+
--docsearch-modal-background: #fafafa;
12+
--docsearch-searchbox-focus-background: transparent;
13+
--docsearch-searchbox-shadow: none;
914
}
1015

1116
body {
@@ -708,3 +713,13 @@ perfect-scrollbar.ps-show-active.ps-show-limits
708713
}
709714
}
710715
}
716+
717+
.DocSearch-Modal {
718+
margin-top: 120px;
719+
border-radius: 3px;
720+
}
721+
722+
.DocSearch-Container {
723+
z-index: 20000;
724+
background: rgba(0, 0, 0, 0.6);
725+
}

0 commit comments

Comments
 (0)