|
1 | | -{{ if or .Site.Params.gcs_engine_id .Site.Params.algolia_docsearch }} |
2 | | -<div class="search-bar"> |
3 | | - <i class="search-icon fa-solid fa-search"></i> |
4 | | - <input |
5 | | - type="search" |
6 | | - class="search-input td-search-input" |
7 | | - placeholder="{{ T "ui_search_placeholder" }}" |
8 | | - aria-label="{{ T "ui_search_placeholder" }}" |
9 | | - autocomplete="off" |
10 | | - > |
11 | | -</div> |
12 | | -{{ else if .Site.Params.offlineSearch }} |
13 | | -<div class="search-bar" id="search-nav-container"> |
14 | | - <i class="search-icon fa-solid fa-search"></i> |
15 | | - <input |
16 | | - type="search" |
17 | | - class="search-input td-search-input" |
18 | | - id="search-input" |
19 | | - placeholder="{{ T "ui_search_placeholder" }}" |
20 | | - aria-label="{{ T "ui_search_placeholder" }}" |
21 | | - autocomplete="off" |
22 | | - > |
| 1 | +{{ if .Site.Params.gcs_engine_id -}} |
| 2 | +<div class="td-search"> |
| 3 | + <div class="td-search__icon"></div> |
| 4 | + <input type="search" class="td-search__input form-control td-search-input" placeholder="{{ T "ui_search" }}" aria-label="{{ T "ui_search" }}" autocomplete="off"> |
23 | 5 | </div> |
24 | | -{{ else if .Site.Params.k8s_search }} |
25 | | - |
26 | | -{{ $lang := .Site.Language.Lang }} |
27 | | -{{ $searchFile := printf "content/%s/search.md" $lang }} |
| 6 | +{{ else if .Site.Params.algolia_docsearch -}} |
| 7 | +<div id="docsearch"></div> |
| 8 | +{{ else if .Site.Params.offlineSearch -}} |
| 9 | +{{ $offlineSearchIndex := resources.Get "json/offline-search-index.json" | resources.ExecuteAsTemplate "offline-search-index.json" . -}} |
| 10 | +{{ if hugo.IsProduction -}} |
| 11 | +{{/* Use `md5` as finger print hash function to shorten file name to avoid `file name too long` error. */ -}} |
| 12 | +{{ $offlineSearchIndex = $offlineSearchIndex | fingerprint "md5" -}} |
| 13 | +{{ end -}} |
| 14 | +{{ $offlineSearchLink := $offlineSearchIndex.RelPermalink -}} |
28 | 15 |
|
29 | | -<div class="search-bar"> |
30 | | - <i class="search-icon fa-solid fa-search"></i> |
| 16 | +<div class="td-search td-search--offline"> |
| 17 | + <div class="td-search__icon"></div> |
31 | 18 | <input |
32 | 19 | type="search" |
33 | | - name="q" |
34 | | - {{ if fileExists $searchFile }} |
35 | | - data-search-page="{{ "search/" | relLangURL }}" |
36 | | - {{ else }} |
37 | | - data-search-page="{{ "search/" | relURL }}" |
38 | | - {{ end }} |
39 | | - class="search-input td-search-input" |
40 | | - placeholder="{{ T "ui_search_placeholder" }}" |
41 | | - aria-label="{{ T "ui_search_placeholder" }}" |
| 20 | + class="td-search__input form-control" |
| 21 | + placeholder="{{ T "ui_search" }}" |
| 22 | + aria-label="{{ T "ui_search" }}" |
42 | 23 | autocomplete="off" |
| 24 | + {{/* |
| 25 | + The data attribute name of the json file URL must end with `src` since |
| 26 | + Hugo's absurlreplacer requires `src`, `href`, `action` or `srcset` suffix for the attribute name. |
| 27 | + If the absurlreplacer is not applied, the URL will start with `/`. |
| 28 | + It causes the json file loading error when when relativeURLs is enabled. |
| 29 | + https://github.com/google/docsy/issues/181 |
| 30 | + */}} |
| 31 | + data-offline-search-index-json-src="{{ $offlineSearchLink }}" |
| 32 | + data-offline-search-base-href="/" |
| 33 | + data-offline-search-max-results="{{ .Site.Params.offlineSearchMaxResults | default 10 }}" |
43 | 34 | > |
44 | 35 | </div> |
45 | | -{{ end }} |
| 36 | +{{ else if .Site.Params.customSearch -}} |
| 37 | + {{ partialCached "search-input-custom" . }} |
| 38 | +{{ end -}} |
0 commit comments