Skip to content

Commit

Permalink
Upgrade DocSearch UI to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Heeam-Shin committed Apr 13, 2022
1 parent 1d64486 commit e90693a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
9 changes: 6 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@
ga('send', 'pageview');
</script>
{{ end }}
<!-- Algolia DocSearch, Reference: https://community.algolia.com/docsearch/dropdown.html -->
<!-- Algolia DocSearch v3, Reference: https://docsearch.algolia.com/docs/DocSearch-v3 -->
<!-- Before the closing </head> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css">
</head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha"
/>
</head>
5 changes: 1 addition & 4 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
{{ end }}
<span class="navbar-item">
<p class="control has-icons-right">
<input class="input" type="text" placeholder="Search">
<span class="icon is-small is-right">
<i class="fa fa-search"></i>
</span>
<div id="docsearch"></div>
</p>
</span>
<!--
Expand Down
21 changes: 8 additions & 13 deletions layouts/partials/scripts-footer.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
{{/* partial "cookies-popup.html" . */}}
{{ partial "javascript.html" . }}
{{ if eq (getenv "HUGO_ENV") "production" }}
<!-- Algolia DocSearch, Reference: https://community.algolia.com/docsearch/dropdown.html -->
<!-- Algolia DocSearch, Reference: https://docsearch.algolia.com/docs/DocSearch-v3 -->
<!-- Before the closing </body> -->
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script>
<script src="{{ "js/docsearch-v3.js" | relURL }}"></script>
{{ if eq (getenv "HUGO_ENV") "production" }}
<script>
docsearch({
// Your apiKey and indexName will be given to you once
// we create your config
apiKey: {{ getenv "SEARCH_API_KEY" }},
container: '#docsearch',
appId: {{ getenv "SEARCH_APP_ID" }},
indexName: {{ getenv "SEARCH_INDEX_NAME" }},
appId: {{ getenv "SEARCH_APP_ID" }}, // Should be only included if you are running DocSearch on your own.
// Replace inputSelector with a CSS selector
// matching your search input
inputSelector: 'input',
// Set debug to true if you want to inspect the dropdown
debug: false,
apiKey: {{ getenv "SEARCH_API_KEY" }},
});
</script>
{{ end }}
{{ end }}
2 changes: 2 additions & 0 deletions static/js/docsearch-v3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import docsearch from '@docsearch/js';
import '@docsearch/css';

0 comments on commit e90693a

Please sign in to comment.