mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
i18n: mention no support for Czech in Lunr #455
This commit is contained in:
parent
a402c89a19
commit
6659d841ab
4 changed files with 8 additions and 7 deletions
|
@ -42,7 +42,7 @@ title = "Hugo Relearn Documentation"
|
|||
disableHugoGeneratorInject = true
|
||||
|
||||
[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
|
||||
# add PRINT to home, section and page to activate the feature to print whole
|
||||
# chapters
|
||||
|
|
|
@ -130,7 +130,7 @@ If not already present, add the following lines in the same `config.toml` file.
|
|||
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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
{{% 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:
|
||||
|
||||
- Czech
|
||||
- Indonesian
|
||||
- Polish
|
||||
{{% /notice %}}
|
||||
|
|
|
@ -10,7 +10,7 @@ var lunrIndex, pagesIndex;
|
|||
|
||||
function initLunrIndex( 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
|
||||
lunrIndex = lunr(function() {
|
||||
this.use(lunr.multiLanguage.apply(null, contentLangs));
|
||||
|
@ -28,7 +28,7 @@ function initLunrIndex( index ){
|
|||
this.pipeline.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) {
|
||||
page.index = idx;
|
||||
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
|
||||
* @return {Array} results
|
||||
*/
|
||||
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
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue