Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce search #142

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ params:
github_base_url: "https://github.com/vmware-tanzu/cartographer-site"
use_advanced_docs: true
docs_right_sidebar: true
docs_search: false
docs_search_index_name: index_name
docs_search_api_key: api_key
docs_search: true
docs_search_index_name: cartographer
docs_search_api_key: 317b964ff8aeac73a046144087278c2f
docs_search_app_id: NHZFDXXGYL
docs_versioning: true
docs_latest: v0.4.0
docs_versions:
Expand Down
23 changes: 13 additions & 10 deletions themes/template/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{{ $options := (dict "targetPath" "css/style.css" "outputStyle" "compressed" "enableSourceMap" true "includePaths" (slice "node_modules/myscss")) }}
{{ $style := resources.Get "scss/site.scss" | resources.ToCSS $options }}
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}" media="screen">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/></pre></li>
<link rel="icon" type="image/png" href="/img/cartographer-logo-favicon.svg">
<script src="{{ "js/main.js" | relURL }}" type="text/javascript"></script>
{{ with .OutputFormats.Get "RSS" -}}
Expand All @@ -24,16 +25,18 @@
{{ end }}
{{ partial "footer" . }}
{{ if .Site.Params.docs_search }}
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript"> docsearch({
apiKey: '{{ .Site.Params.Docs_search_api_key }}',
indexName: '{{ .Site.Params.Docs_search_index_name }}',
inputSelector: '.docsearch-input',
algoliaOptions: {'facetFilters': ["version:{{ .CurrentSection.Params.version }}"]},
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
{{ end }}
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
<script type="text/javascript">
docsearch({
apiKey: '{{ .Site.Params.Docs_search_api_key }}',
appId: '{{ .Site.Params.Docs_search_app_id }}',
indexName: '{{ .Site.Params.Docs_search_index_name }}',
container: '#doc-search',
algoliaOptions: {'facetFilters': ["version:{{ .CurrentSection.Params.version }}"]},
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
{{ end }}
<script type="text/javascript"> addCopyButtons(navigator.clipboard);</script>
</body>
</html>
20 changes: 11 additions & 9 deletions themes/template/layouts/_default/search.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{{ if .Site.Params.docs_search }}
<form class="d-flex align-items-center">
<span class="algolia-autocomplete" style="position: relative; display: inline-block; direction: ltr;">
<input type="search" class="form-control docsearch-input" id="search-input" placeholder="Search..."
aria-label="Search for..." autocomplete="off" spellcheck="false" role="combobox"
aria-autocomplete="list" aria-expanded="false" aria-owns="algolia-autocomplete-listbox-0"
dir="auto" style="position: relative; vertical-align: top;">
</span>
</form>
{{ end }}
<div id="doc-search"></div>
<!-- <form class="d-flex align-items-center">-->
<!-- <span class="algolia-autocomplete" style="position: relative; display: inline-block; direction: ltr;">-->
<!-- <input type="search" class="form-control docsearch-input" id="search-input" placeholder="Search..."-->
<!-- aria-label="Search for..." autocomplete="off" spellcheck="false" role="combobox"-->
<!-- aria-autocomplete="list" aria-expanded="false" aria-owns="algolia-autocomplete-listbox-0"-->
<!-- dir="auto" style="position: relative; vertical-align: top;">-->
<!-- </span>-->
<!-- </form>-->
{{ end }}