From 450840b51131b926b1a24362641bf67b73c03e4b Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Thu, 13 Apr 2023 17:03:32 +0000
Subject: [PATCH] fix placeholder bug #107
---
layouts/partials/search.html | 36 +++++++++++++++++++-----------------
i18n/en.toml | 2 +-
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/i18n/en.toml b/i18n/en.toml
index 5146749..a75f74b 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -13,7 +13,7 @@
[quick_links]
other = "Quick links"
[search_field_placeholder]
- other = "Search {{ .section }}"
+ other = "Search"
[search_results_label]
other = "Search Results"
[short_search_query]
diff --git a/layouts/partials/search.html b/layouts/partials/search.html
index c6ee3e0..17988b7 100644
--- a/layouts/partials/search.html
+++ b/layouts/partials/search.html
@@ -1,18 +1,20 @@
-{{ $searchEnabled := partialCached "functions/getSearchConfig" . }}
-{{ if $searchEnabled }}
-<div class="search">
- <label for="find" class="search_label">
- {{- partial "sprite" (dict "icon" "search") }}
- </label>
- {{ $placeholder := T "search_field_placeholder" (dict "section" .Section) }}
- {{ if .Section }}
- {{ else }}
- {{ $placeholder = printf "%s%s" $placeholder (T "site") }}
- {{ end }}
- <input type="search" class="search_field standardize-input" placeholder="{{ $placeholder }}" id="find" autocomplete="off" data-scope='{{ .Section }}'>
- {{- if ne .Params.searchPage true }}
- <div class="search_results results"></div>
+{{- $searchEnabled := partialCached "functions/getSearchConfig" . }}
+{{- if $searchEnabled }}
+ {{- $section := .Section }}
+ {{- $config := site.Params }}
+ {{- $default := T "search_field_placeholder" }}
+ {{- $scope := T "site" }}
+ {{- if and $section (eq $config.search.global false) }}
+ {{- $scope = $section }}
{{- end }}
-</div>
-{{ end }}
-
+ <div class="search">
+ <label for="find" class="search_label">
+ {{- partial "sprite" (dict "icon" "search") }}
+ </label>
+ {{ $placeholder := printf "%s %s" $default $scope }}
+ <input type="search" class="search_field standardize-input" placeholder="{{ $placeholder }}" id="find" autocomplete="off" data-scope='{{ $section }}'>
+ {{- if ne .Params.searchPage true }}
+ <div class="search_results results"></div>
+ {{- end }}
+ </div>
+{{- end }}
\ No newline at end of file
--
Gitblit v1.10.0