i18n: fix search for cyrillic #269

This commit is contained in:
Sören Weber 2022-06-12 14:05:01 +02:00
parent 1131c68aae
commit c7b2eee5a6
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 11 additions and 1 deletions

View file

@ -4,6 +4,12 @@
<span data-search-clear=""><i class="fas fa-times"></i></span> <span data-search-clear=""><i class="fas fa-times"></i></span>
</div> </div>
{{- $assetBusting := not .Site.Params.disableAssetsBusting }} {{- $assetBusting := not .Site.Params.disableAssetsBusting }}
<script src="{{"js/lunr.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script> {{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Lang }}
<script>
var pageBaseLang="{{ $pageBaseLang }}";
</script>
<script src="{{"js/auto-complete.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{"js/auto-complete.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/lunr.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/lunr.stemmer.support.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{ (printf "js/lunr.%s.min.js" $pageBaseLang) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{ "js/search.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script> <script src="{{ "js/search.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}"></script>

View file

@ -9,6 +9,10 @@ function initLunr() {
// Set up lunrjs by declaring the fields we use // Set up lunrjs by declaring the fields we use
// Also provide their boost level for the ranking // Also provide their boost level for the ranking
lunrIndex = lunr(function() { lunrIndex = lunr(function() {
if(lunr[pageBaseLang]){
this.use(lunr[pageBaseLang]);
}
this.ref('index'); this.ref('index');
this.field('title', { this.field('title', {
boost: 15 boost: 15