File tree Expand file tree Collapse file tree 6 files changed +21
-4
lines changed
content/examples/shortcodes/search
content/en/examples/shortcodes/search Expand file tree Collapse file tree 6 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ With this shortcode you can embed a search results widget on the page.
8
8
## Example
9
9
10
10
```
11
- {{</* search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" */>}}
11
+ {{</* search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" searchTerm="json" */>}}
12
12
```
13
13
14
- {{< search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" >}}
14
+ {{< search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" searchTerm="json" >}}
15
15
16
16
17
17
## Attributes
@@ -24,3 +24,6 @@ showContentTypes
24
24
25
25
tags
26
26
: optional - Adds preselected tags
27
+
28
+ searchTerm
29
+ : optional - Prefills the search bar
Original file line number Diff line number Diff line change @@ -173,6 +173,11 @@ export class SearchFilter extends BaseWidget {
173
173
this . selectedItems = selectedItems ;
174
174
175
175
if ( urlParamsChanged ) {
176
+ const initialSearchTerm = this . element . dataset . initialSearchTerm ;
177
+ if ( initialSearchTerm ) {
178
+ this . parsedQuery . cleanQuery = initialSearchTerm ;
179
+ }
180
+
176
181
this . updateUrl ( false ) ;
177
182
}
178
183
}
Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ With this shortcode you can embed a search results widget on the page.
8
8
## Example
9
9
10
10
```
11
- {{</* search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" */>}}
11
+ {{</* search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" searchTerm="json" */>}}
12
12
```
13
13
14
- {{< search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" >}}
14
+ {{< search contentType="How-to Guides" showContentTypes=false tags="encodings,commented cue" searchTerm="json" >}}
15
15
16
16
17
17
## Attributes
@@ -24,3 +24,6 @@ showContentTypes
24
24
25
25
tags
26
26
: optional - Adds preselected tags
27
+
28
+ searchTerm
29
+ : optional - Prefills the search bar
Original file line number Diff line number Diff line change 8
8
{{ $inputLabel := printf "search_%s_input" $translationKey }}
9
9
{{ $noResults := printf "search_%s_no-results" $translationKey }}
10
10
{{ $preselectedItems := .preselectedItems }}
11
+ {{ $searchTerm := .searchTerm }}
11
12
12
13
< details class ="filter{{ if $cssClass }} {{ $cssClass }}{{ end }} is-loading "
13
14
data-dropdown data-filter ="{{ $name }} "
14
15
data-filter-items ="{{ $filters | jsonify }} "
15
16
{{ if $preselectedItems }} data-preselected-items ="{{ $preselectedItems }} "{{ end }}
17
+ {{ if $searchTerm }} data-initial-search-term ="{{ $searchTerm }} "{{ end }}
16
18
{{ if $open }} open{{ end }}
17
19
>
18
20
< summary class ="filter__title button button--small button--white ">
Original file line number Diff line number Diff line change 3
3
{{ $contentTypes := slice }}
4
4
{{ $contentType := .contentType | default "" }}
5
5
{{ $preselectedTags := .preselectedTags | default "" }}
6
+ {{ $searchTerm := .searchTerm | default "" }}
6
7
{{ $type := .type | default "full" }}
7
8
{{ $placeholder := (T "search_placeholder" ) }}
8
9
48
49
"name" "tags"
49
50
"filters" .Site.Params.tags
50
51
"preselectedItems" $preselectedTags
52
+ "searchTerm" $searchTerm
51
53
) -}}
52
54
53
55
{{ if $showContentTypes }}
Original file line number Diff line number Diff line change 1
1
{{- $contentType := .Get "contentType" | default "" -}}
2
2
{{- $showContentTypes := .Get "showContentTypes" | default true -}}
3
3
{{- $preselectedTags := .Get "tags" | default "" -}}
4
+ {{- $searchTerm := .Get "searchTerm" | default "" -}}
4
5
5
6
{{- partial "search" (dict
6
7
"type" "widget"
7
8
"contentType" $contentType
8
9
"showContentTypes" $showContentTypes
9
10
"preselectedTags" $preselectedTags
11
+ "searchTerm" $searchTerm
10
12
"context" .
11
13
) -}}
You can’t perform that action at this time.
0 commit comments