Make search multilingual (#305)
* Make search multilingual * Added Support for custom country flags * Add search.md for more language + fix search behavior Signed-off-by: hossainemruz <hossainemruz@gmail.com> Co-authored-by: Pablo Marcos <codebergflamingo@staplehorse.anonaddy.com> Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
parent
16f64aa4c2
commit
ac28e9824e
34 changed files with 1315 additions and 17 deletions
|
@ -16,7 +16,7 @@
|
|||
<section class="sidebar-section" id="sidebar-section">
|
||||
<div class="sidebar-holder">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | absURL }}">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
|
||||
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
|
||||
</form>
|
||||
<div class="sidebar-tree">
|
||||
|
@ -36,7 +36,8 @@
|
|||
<section class="content-section" id="content-section">
|
||||
<div class="content container-fluid" id="content">
|
||||
<div class="container-fluid post-card-holder" id="post-card-holder">
|
||||
{{ $paginator := .Paginate .RegularPagesRecursive 12 }}
|
||||
{{ $posts := where .RegularPagesRecursive "Layout" "!=" "search" }}
|
||||
{{ $paginator := .Paginate $posts 12 }}
|
||||
{{ range $paginator.Pages }}
|
||||
{{ if .Layout }}
|
||||
{{/* ignore the search.md file*/}}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<section class="sidebar-section" id="sidebar-section">
|
||||
<div class="sidebar-holder">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | absURL }}">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
|
||||
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
|
||||
</form>
|
||||
<div class="sidebar-tree">
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<section class="sidebar-section" id="sidebar-section">
|
||||
<div class="sidebar-holder">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | absURL }}">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
|
||||
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
|
||||
</form>
|
||||
<div class="sidebar-tree">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<section class="sidebar-section" id="sidebar-section">
|
||||
<div class="sidebar-holder">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | absURL }}">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
|
||||
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
|
||||
</form>
|
||||
<div class="sidebar-tree">
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<section class="sidebar-section" id="sidebar-section">
|
||||
<div class="sidebar-holder">
|
||||
<div class="sidebar" id="sidebar">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | absURL }}">
|
||||
<form class="mx-auto" method="get" action="{{ "search" | relLangURL }}">
|
||||
<input type="text" name="keyword" value="" placeholder="Search" data-search="" id="search-box" />
|
||||
</form>
|
||||
<div class="sidebar-tree">
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{/* if there is no custom flag provided, we define the flag with the country code */}}
|
||||
{{ $languageCode:= .Lang }}
|
||||
{{/* by default the language code and the country code are same */}}
|
||||
{{/* by default the language code and the country code are same */}}
|
||||
{{ $countryCode:= $languageCode }}
|
||||
|
||||
{{/* language code and country code are not same for some countries. we need to fix them. */}}
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
<div class="dropdown languageSelector">
|
||||
<a class="btn dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<img class="flag" src="https://www.countryflags.io/{{ $countryCode }}/flat/16.png" alt="{{ $countryCode }}">
|
||||
{{ site.Language.LanguageName }}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="languageSelector">
|
||||
{{ range .Translations }}
|
||||
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang "en") "" .Language.Lang) $pageURL }}">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<img class="flag" src="https://www.countryflags.io/{{ $countryCode }}/flat/24.png" alt="{{ $countryCode }}">
|
||||
{{ .Language.LanguageName }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
|
||||
{{ site.Language.LanguageName }}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="languageSelector">
|
||||
{{ range .Translations }}
|
||||
<a class="dropdown-item nav-link languages-item" href="{{ path.Join "/" (cond (eq .Language.Lang "en") "" .Language.Lang) $pageURL }}">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
|
||||
{{ .Language.LanguageName }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</li>
|
||||
</li>
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="languageSelector" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
|
||||
{{ site.Language.LanguageName }}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="languageSelector">
|
||||
{{ range site.Home.AllTranslations }}
|
||||
<a class="dropdown-item nav-link languages-item" href="{{ .RelPermalink }}">
|
||||
{{ $countryCode := partial "helpers/country-code.html" .Language }}
|
||||
{{ $countryCode := partial "helpers/country-code.html" . }}
|
||||
<span class="flag-icon flag-icon-{{$countryCode}}"></span>
|
||||
{{ .Language.LanguageName }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</li>
|
||||
</li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue