#87, Add support for multilang search index generation
This commit is contained in:
parent
05c3b8fac9
commit
7b52bf4232
5 changed files with 22 additions and 15 deletions
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
const indexCfg = {{ with .Site.Params.BookSearchConfig }}
|
const indexCfg = {{ with .Site.Params.BookSearchConfig }}
|
||||||
{{ . }}
|
{{ . }};
|
||||||
{{ end }};
|
{{ else }}
|
||||||
|
{};
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
indexCfg.doc = {
|
indexCfg.doc = {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
{{- $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate "search-data.js" . | resources.Minify | resources.Fingerprint }}
|
{{ $searchDataFile := printf "%s.%s" .Language.Lang "search-data.js" }}
|
||||||
|
{{ $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
const input = document.querySelector('#book-search-input');
|
const input = document.querySelector('#book-search-input');
|
||||||
const results = document.querySelector('#book-search-results');
|
const results = document.querySelector('#book-search-results');
|
||||||
|
|
|
@ -20,9 +20,11 @@ defaultContentLanguage = 'en'
|
||||||
[languages.en]
|
[languages.en]
|
||||||
languageName = 'English'
|
languageName = 'English'
|
||||||
weight = 1
|
weight = 1
|
||||||
|
|
||||||
[languages.ru]
|
[languages.ru]
|
||||||
languageName = 'Russian'
|
languageName = 'Russian'
|
||||||
weight = 2
|
weight = 2
|
||||||
|
|
||||||
[languages.cn]
|
[languages.cn]
|
||||||
languageName = 'Chinese'
|
languageName = 'Chinese'
|
||||||
weight = 3
|
weight = 3
|
||||||
|
@ -63,7 +65,7 @@ defaultContentLanguage = 'en'
|
||||||
# Index is built on fly, therefore it might slowdown your website.
|
# Index is built on fly, therefore it might slowdown your website.
|
||||||
BookSearch = true
|
BookSearch = true
|
||||||
|
|
||||||
# (Optional, default none) Search config for flexsearch index.
|
# (Optional, default {}) Search config for flexsearch index.
|
||||||
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
|
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
|
||||||
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
|
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
|
||||||
BookSearchConfig = '{ cache: true }'
|
BookSearchConfig = '{ cache: true }'
|
||||||
|
|
|
@ -63,7 +63,7 @@ params:
|
||||||
# Index is built on fly, therefore it might slowdown your website.
|
# Index is built on fly, therefore it might slowdown your website.
|
||||||
BookSearch: true
|
BookSearch: true
|
||||||
|
|
||||||
# (Optional, default none) Search config for flexsearch index.
|
# (Optional, default {}) Search config for flexsearch index.
|
||||||
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
|
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
|
||||||
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
|
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
|
||||||
BookSearchConfig: |
|
BookSearchConfig: |
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
|
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
|
||||||
|
|
||||||
{{ if default true .Site.Params.BookSearch }}
|
{{ if default true .Site.Params.BookSearch }}
|
||||||
{{- $searchJS := resources.Get "search.js" | resources.ExecuteAsTemplate "search.js" . | resources.Minify | resources.Fingerprint }}
|
{{- $searchJSFile := printf "%s.%s" .Language.Lang "search.js" -}}
|
||||||
|
{{- $searchJS := resources.Get "search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify | resources.Fingerprint }}
|
||||||
<script defer src="{{ $searchJS.RelPermalink }}" integrity="{{ $searchJS.Data.Integrity }}"></script>
|
<script defer src="{{ $searchJS.RelPermalink }}" integrity="{{ $searchJS.Data.Integrity }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue