Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Vimux/mainroad.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVimux <Vimux@users.noreply.github.com>2022-08-18 19:33:28 +0300
committerGitHub <noreply@github.com>2022-08-18 19:33:28 +0300
commit73e745cf9826b623a6de13ffb9700232f7242638 (patch)
treefdabbb8c5fc06c216dd024612457150a23a7731b
parent8b4ca24036e7940ab025684ceeecdd52754cf689 (diff)
parent68e677f170441b26895db8f5abb9e4c87c1bb700 (diff)
Merge pull request #298 from Vimux/merge-search-widgets
Merge two search widgets into one
-rw-r--r--README.md7
-rw-r--r--exampleSite/content/docs/customization.md37
-rw-r--r--layouts/partials/widgets/ddg-search.html1
-rw-r--r--layouts/partials/widgets/search.html8
4 files changed, 49 insertions, 4 deletions
diff --git a/README.md b/README.md
index e1e051d..fb9101e 100644
--- a/README.md
+++ b/README.md
@@ -111,8 +111,6 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
single = false # Configure layout for single pages
# Enable widgets in given order
widgets = ["search", "recent", "categories", "taglist", "social", "languages"]
- # alternatively "ddg-search" can be used, to search via DuckDuckGo
- # widgets = ["ddg-search", "recent", "categories", "taglist", "social", "languages"]
[Params.widgets]
recent_num = 5 # Set the number of articles in the "Recent articles" widget
@@ -140,6 +138,11 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
[[Params.widgets.social.custom]]
title = "My Home Page"
url = "https://example.com"
+
+[Params.widgets.search]
+ url = "https://google.com/search"
+ input.name = "sitesearch"
+ input.pre = ""
```
**Do not copy example config as-is**. Use only those parameters that you need.
diff --git a/exampleSite/content/docs/customization.md b/exampleSite/content/docs/customization.md
index 0b4a664..d28a980 100644
--- a/exampleSite/content/docs/customization.md
+++ b/exampleSite/content/docs/customization.md
@@ -130,6 +130,8 @@ Full list of available default widgets:
* `search`, `ddg-search`, `recent`, `categories`, `taglist`, `social`, `languages`
+**Note**: DuckDuckGo widget (`ddg-search`) deprecated in favor of `search` widget.
+
---
Some of our widgets respect optional configuration. Have a look at the `[Params.widgets]` and `[Params.widgets.social]`
@@ -186,6 +188,41 @@ custom SVG icon needs these attributes:
<svg class="{{ with .class }}{{ . }} {{ end }} icon" width="24" height="24">...</svg>
```
+### Search box widget
+
+The search box widget can refer to the results of Google, Bing, and DuckDuckGo searches. By default, Mainroad uses
+Google search if no additional configuration options are specified.
+
+To use a different search engine, first of all, check that the search widget is enabled. Then set the search parameters
+(`Site.Params.widgets.search` section) according to the data below.
+
+**Google (default)**:
+
+```toml
+[Params.widgets.search]
+ url = "https://google.com/search"
+ input.name = "sitesearch"
+ input.pre = ""
+```
+
+**DuckDuckGo**:
+
+```toml
+[Params.widgets.search]
+ url = "https://duckduckgo.com/"
+ input.name = "sites"
+ input.pre = ""
+```
+
+**Bing**:
+
+```toml
+[Params.widgets.search]
+ url = "https://www.bing.com/search"
+ input.name = "q1"
+ input.pre = "site:"
+```
+
### Menus
**Mainroad** supports multiple menus. The `main` menu is fully responsive and displayed right under the site header. The
diff --git a/layouts/partials/widgets/ddg-search.html b/layouts/partials/widgets/ddg-search.html
index 8c8da20..094ca58 100644
--- a/layouts/partials/widgets/ddg-search.html
+++ b/layouts/partials/widgets/ddg-search.html
@@ -1,3 +1,4 @@
+<!-- DEPRECATED WIDGET! DON'T USE IT! -->
<div class="widget-search widget">
<form class="widget-search__form" role="search" method="get" action="https://duckduckgo.com/">
<label>
diff --git a/layouts/partials/widgets/search.html b/layouts/partials/widgets/search.html
index d6b1652..e29b6ca 100644
--- a/layouts/partials/widgets/search.html
+++ b/layouts/partials/widgets/search.html
@@ -1,9 +1,13 @@
+{{- $actionURL := .Site.Params.widgets.search.url | default "https://google.com/search" -}}
+{{- $inputName := .Site.Params.widgets.search.input.name | default "sitesearch" -}}
+{{- $inputPre := .Site.Params.widgets.search.input.pre -}}
+
<div class="widget-search widget">
- <form class="widget-search__form" role="search" method="get" action="https://google.com/search">
+ <form class="widget-search__form" role="search" method="get" action="{{ $actionURL }}">
<label>
<input class="widget-search__field" type="search" placeholder="{{ T "search_placeholder" }}" value="" name="q" aria-label="{{ T "search_placeholder" }}">
</label>
<input class="widget-search__submit" type="submit" value="Search">
- <input type="hidden" name="sitesearch" value="{{ .Site.BaseURL }}" />
+ {{ if $inputName -}}<input type="hidden" name="{{ $inputName }}" value="{{ $inputPre }}{{ .Site.BaseURL }}">{{- end }}
</form>
</div> \ No newline at end of file