Skip to content

Commit

Permalink
i18n: mention no support for Czech in Lunr matcornic#455
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Jan 30, 2023
1 parent a402c89 commit 6659d84
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/basics/configuration/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion exampleSite/content/cont/i18n/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}
Expand Down
8 changes: 4 additions & 4 deletions static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6659d84

Please sign in to comment.