aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--assets/_custom.scss4
-rw-r--r--assets/_variables.scss4
-rw-r--r--assets/search-data.js2
-rw-r--r--assets/search.js2
-rw-r--r--exampleSite/assets/_custom.scss2
-rw-r--r--exampleSite/assets/_variables.scss2
-rw-r--r--exampleSite/config.toml6
-rw-r--r--exampleSite/config.yaml8
-rw-r--r--i18n/cn.yaml9
-rw-r--r--i18n/en.yaml3
-rw-r--r--i18n/ru.yaml3
-rw-r--r--layouts/partials/docs/footer.html4
-rw-r--r--layouts/partials/docs/html-head.html3
14 files changed, 32 insertions, 27 deletions
diff --git a/README.md b/README.md
index 30d4274..babb1a2 100644
--- a/README.md
+++ b/README.md
@@ -160,14 +160,9 @@ disableKinds = ['taxonomy', 'taxonomyTerm']
# - In blog posts
BookDateFormat = 'Jan 2, 2006'
- # (Optional, default true) Enables search function with lunr.js,
+ # (Optional, default true) Enables search function with flexsearch,
# Index is built on fly, therefore it might slowdown your website.
BookSearch = true
-
- # (Optional, default none) Search config for flexsearch index.
- # 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.
- BookSearchConfig = '{ cache: true }'
```
### Page Configuration
diff --git a/assets/_custom.scss b/assets/_custom.scss
index 75c4833..0de9ae1 100644
--- a/assets/_custom.scss
+++ b/assets/_custom.scss
@@ -1 +1,3 @@
-/* To be overridden by theme user, scss variables are also accessible here */
+/* You can add custom styles here. */
+
+// @import "plugins/numbered";
diff --git a/assets/_variables.scss b/assets/_variables.scss
index 5cbcc8c..6e34d16 100644
--- a/assets/_variables.scss
+++ b/assets/_variables.scss
@@ -1 +1,3 @@
-/* To be overridden by theme user, e.g. set SASS vars*/
+/* You can override SASS variables here. */
+
+// @import "plugins/dark";
diff --git a/assets/search-data.js b/assets/search-data.js
index 9c7f6a9..cb7c8da 100644
--- a/assets/search-data.js
+++ b/assets/search-data.js
@@ -1,7 +1,7 @@
'use strict';
(function() {
- const indexCfg = {{ with .Site.Params.BookSearchConfig }}
+ const indexCfg = {{ with .Scratch.Get "bookSearchConfig" }}
{{ . }};
{{ else }}
{};
diff --git a/assets/search.js b/assets/search.js
index f21d4bf..9b1c5ab 100644
--- a/assets/search.js
+++ b/assets/search.js
@@ -1,6 +1,6 @@
'use strict';
-{{ $searchDataFile := printf "%s.%s" .Language.Lang "search-data.js" }}
+{{ $searchDataFile := printf "%s.search-data.js" .Language.Lang }}
{{ $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}
(function() {
diff --git a/exampleSite/assets/_custom.scss b/exampleSite/assets/_custom.scss
index 38b16a2..0de9ae1 100644
--- a/exampleSite/assets/_custom.scss
+++ b/exampleSite/assets/_custom.scss
@@ -1,3 +1,3 @@
-// You can add custom styles here.
+/* You can add custom styles here. */
// @import "plugins/numbered";
diff --git a/exampleSite/assets/_variables.scss b/exampleSite/assets/_variables.scss
index 431dabc..6e34d16 100644
--- a/exampleSite/assets/_variables.scss
+++ b/exampleSite/assets/_variables.scss
@@ -1,3 +1,3 @@
-/* You can override SASS variables here. Below example of simple dark theme. */
+/* You can override SASS variables here. */
// @import "plugins/dark";
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 96e8165..27e1b13 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -61,11 +61,7 @@ defaultContentLanguage = 'en'
# - In blog posts
BookDateFormat = 'Jan 2, 2006'
- # (Optional, default true) Enables search function with lunr.js,
+ # (Optional, default true) Enables search function with flexsearch,
# Index is built on fly, therefore it might slowdown your website.
BookSearch = true
- # (Optional, default {}) Search config for flexsearch index.
- # 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.
- BookSearchConfig = '{ cache: true }'
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 6db35ed..3d8dedc 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -59,12 +59,6 @@ params:
# - In blog posts
BookDateFormat: 'Jan 2, 2006'
- # (Optional, default true) Enables search function with lunr.js,
+ # (Optional, default true) Enables search function with flexsearch,
# Index is built on fly, therefore it might slowdown your website.
BookSearch: true
-
- # (Optional, default {}) Search config for flexsearch index.
- # 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.
- BookSearchConfig: |
- { cache: true }
diff --git a/i18n/cn.yaml b/i18n/cn.yaml
index fbef15a..6b1bd69 100644
--- a/i18n/cn.yaml
+++ b/i18n/cn.yaml
@@ -3,3 +3,12 @@
- id: Edit this page
translation: Edit this page
+
+- id: bookSearchConfig
+ translation: |
+ {
+ encode: false,
+ tokenize: function(str) {
+ return str.replace(/[\x00-\x7F]/g, '').split('');
+ }
+ }
diff --git a/i18n/en.yaml b/i18n/en.yaml
index 5398302..9068bd9 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -3,3 +3,6 @@
- id: Edit this page
translation: Edit this page
+
+- id: bookSearchConfig
+ translation: '{ cache: true }'
diff --git a/i18n/ru.yaml b/i18n/ru.yaml
index 8093dbc..7717f5d 100644
--- a/i18n/ru.yaml
+++ b/i18n/ru.yaml
@@ -3,3 +3,6 @@
- id: Edit this page
translation: Редактировать эту сраницу
+
+- id: bookSearchConfig
+ translation: '{ split: /[^a-zа-яё0-9\w]/gi }'
diff --git a/layouts/partials/docs/footer.html b/layouts/partials/docs/footer.html
index 15d1640..ac05ae7 100644
--- a/layouts/partials/docs/footer.html
+++ b/layouts/partials/docs/footer.html
@@ -1,5 +1,5 @@
{{ if or .GitInfo .Site.Params.BookEditPath }}
-<div class="book-footer {{ if not .GitInfo }}justify-end{{ else }}justify-between{{ end }}">
+<div class="book-footer justify-between">
{{ partial "docs/languages" . }}
{{ with .GitInfo }}
<div>
@@ -14,7 +14,7 @@
<div>
{{ if $.File }}
<a class="flex align-center" href="{{ $.Site.Params.BookRepo }}/{{ . }}/{{ $.File.Path }}" target="_blank" rel="noopener">
- <img src="{{ "svg/edit.svg" | relURL }}" alt="Edit" />
+ <img src="{{ "svg/edit.svg" | relURL }}" alt="{{ i18n "Edit this page" }}" />
<span>{{ i18n "Edit this page" }}</span>
</a>
{{ end }}
diff --git a/layouts/partials/docs/html-head.html b/layouts/partials/docs/html-head.html
index c3a692f..153ab35 100644
--- a/layouts/partials/docs/html-head.html
+++ b/layouts/partials/docs/html-head.html
@@ -10,7 +10,8 @@
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
{{ if default true .Site.Params.BookSearch }}
-{{- $searchJSFile := printf "%s.%s" .Language.Lang "search.js" -}}
+{{- .Scratch.Set "bookSearchConfig" (i18n "bookSearchConfig") -}}} <!-- Remove after https://github.com/gohugoio/hugo/issues/6331 -->
+{{- $searchJSFile := printf "%s.search.js" .Language.Lang -}}
{{- $searchJS := resources.Get "search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify | resources.Fingerprint }}
<script defer src="{{ $searchJS.RelPermalink }}" integrity="{{ $searchJS.Data.Integrity }}"></script>
{{ end }}