From 13584878c23146c7093c8d1b9150ff9a98d28c8b Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Thu, 14 Nov 2019 00:23:01 +0100 Subject: Polish multilang mode, update docs --- README.md | 7 +------ assets/_custom.scss | 4 +++- assets/_variables.scss | 4 +++- assets/search-data.js | 2 +- assets/search.js | 2 +- exampleSite/assets/_custom.scss | 2 +- exampleSite/assets/_variables.scss | 2 +- exampleSite/config.toml | 6 +----- exampleSite/config.yaml | 8 +------- i18n/cn.yaml | 9 +++++++++ i18n/en.yaml | 3 +++ i18n/ru.yaml | 3 +++ layouts/partials/docs/footer.html | 4 ++-- layouts/partials/docs/html-head.html | 3 ++- 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 }} -