i18n: mention no support for Czech in Lunr #455

This commit is contained in:
Sören Weber 2023-01-30 17:59:28 +01:00
parent a402c89a19
commit 6659d841ab
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 8 additions and 7 deletions

View file

@ -42,7 +42,7 @@ title = "Hugo Relearn Documentation"
disableHugoGeneratorInject = true disableHugoGeneratorInject = true
[outputs] [outputs]
# add JSON to the home to support lunr search; This is a mandatory setting # add JSON to the home to support Lunr search; This is a mandatory setting
# for the search functionality # for the search functionality
# add PRINT to home, section and page to activate the feature to print whole # add PRINT to home, section and page to activate the feature to print whole
# chapters # chapters

View file

@ -130,7 +130,7 @@ If not already present, add the following lines in the same `config.toml` file.
home = ["HTML", "RSS", "SEARCH"] home = ["HTML", "RSS", "SEARCH"]
``` ```
This will generate a search index file at the root of your public folder ready to be consumed by the lunr.js javascript search engine. Note that the `SEARCH` outputformat was named `JSON` in previous releases but was implemented differently. Although `JSON` still works, it is now deprecated. This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the `SEARCH` outputformat was named `JSON` in previous releases but was implemented differently. Although `JSON` still works, it is now deprecated.
### Activate dedicated search page ### Activate dedicated search page

View file

@ -63,9 +63,10 @@ Use [slug](https://gohugo.io/content-management/multilingual/#translate-your-con
In case each page's content is written in one single language only, the above configuration will already configure the site's search functionality correctly. In case each page's content is written in one single language only, the above configuration will already configure the site's search functionality correctly.
{{% notice warning %}} {{% notice warning %}}
Although the theme supports a wide variety of supported languages, the site's search does not. Although the theme supports a wide variety of supported languages, the site's search via the [Lunr](https://lunrjs.com) search library does not.
You'll see error reports in your browsers console log for each unsupported language. Currently unsupported are: You'll see error reports in your browsers console log for each unsupported language. Currently unsupported are:
- Czech
- Indonesian - Indonesian
- Polish - Polish
{{% /notice %}} {{% /notice %}}

View file

@ -10,7 +10,7 @@ var lunrIndex, pagesIndex;
function initLunrIndex( index ){ function initLunrIndex( index ){
pagesIndex = index; pagesIndex = index;
// Set up lunrjs by declaring the fields we use // Set up Lunr 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() {
this.use(lunr.multiLanguage.apply(null, contentLangs)); this.use(lunr.multiLanguage.apply(null, contentLangs));
@ -28,7 +28,7 @@ function initLunrIndex( index ){
this.pipeline.remove(lunr.stemmer); this.pipeline.remove(lunr.stemmer);
this.searchPipeline.remove(lunr.stemmer); this.searchPipeline.remove(lunr.stemmer);
// Feed lunr with each file and let lunr actually index them // Feed Lunr with each file and let LUnr actually index them
pagesIndex.forEach(function(page, idx) { pagesIndex.forEach(function(page, idx) {
page.index = idx; page.index = idx;
this.add(page); this.add(page);
@ -114,13 +114,13 @@ function initLunrJs() {
} }
/** /**
* Trigger a search in lunr and transform the result * Trigger a search in Lunr and transform the result
* *
* @param {String} term * @param {String} term
* @return {Array} results * @return {Array} results
*/ */
function search(term) { function search(term) {
// Find the item in our index corresponding to the lunr one to have more info // Find the item in our index corresponding to the Lunr one to have more info
// Remove Lunr special search characters: https://lunrjs.com/guides/searching.html // Remove Lunr special search characters: https://lunrjs.com/guides/searching.html
var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).reduce( function(a,token){return a.concat(searchPatterns(token.str))}, []).join(' '); var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).reduce( function(a,token){return a.concat(searchPatterns(token.str))}, []).join(' ');
return !searchTerm || !lunrIndex ? [] : lunrIndex.search(searchTerm).map(function(result) { return !searchTerm || !lunrIndex ? [] : lunrIndex.search(searchTerm).map(function(result) {