Skip to content

Commit

Permalink
Merge branch 'feat/search' of https://github.com/s-pace/docs.nestjs.com
Browse files Browse the repository at this point in the history
… into s-pace-feat/search
  • Loading branch information
kamilmysliwiec committed Dec 2, 2019
2 parents 7d825f8 + 415a90c commit a4a190e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/homepage/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<ng-content></ng-content>
<app-social-wrapper></app-social-wrapper>
<div class="menu-wrapper">
<div class="search-wrapper">
<input id="q" />
</div>
<ul>
<li>
<a
Expand Down
6 changes: 6 additions & 0 deletions src/app/homepage/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,9 @@ header {
display: none;
}
}

.search-wrapper{
margin-right: 2em;
height: 100%;
display: inline-block;
}
17 changes: 17 additions & 0 deletions src/app/homepage/homepage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class HomepageComponent implements OnInit, OnDestroy, AfterViewInit {

ngAfterViewInit() {
this.checkWindowWidth(window.innerWidth);
this.contentRef.appendChild(this.createDocSearchScriptTag())
}

ngOnDestroy() {
Expand Down Expand Up @@ -141,4 +142,20 @@ export class HomepageComponent implements OnInit, OnDestroy, AfterViewInit {
scriptTag.id = '_carbonads_js';
return scriptTag;
}

createDocSearchScriptTag(): HTMLScriptElement {
const scriptTag = document.createElement("script");
scriptTag.type = "text/javascript";
scriptTag.src = "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js";
scriptTag.async = true
scriptTag.onload = () => {
(window as any).docsearch({
apiKey: '9ea53de1a6911255834352bbbe4d3417',
indexName: 'nestjs',
inputSelector: '#q',
debug: false // Set debug to true if you want to inspect the dropdown
})
};
return scriptTag
}
}
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"
></script>
<link href="assets/css/perfect-scrollbar.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

<script>
(function(i, s, o, g, r, a, m) {
Expand Down

0 comments on commit a4a190e

Please sign in to comment.