diff --git a/exampleSite/config.toml b/exampleSite/config.toml index d11f0b2414..9f86e44aea 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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 diff --git a/exampleSite/content/basics/configuration/_index.en.md b/exampleSite/content/basics/configuration/_index.en.md index f894055f70..e2e624d497 100644 --- a/exampleSite/content/basics/configuration/_index.en.md +++ b/exampleSite/content/basics/configuration/_index.en.md @@ -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 diff --git a/exampleSite/content/cont/i18n/_index.en.md b/exampleSite/content/cont/i18n/_index.en.md index 2c70b8aa2b..2d51a528b3 100644 --- a/exampleSite/content/cont/i18n/_index.en.md +++ b/exampleSite/content/cont/i18n/_index.en.md @@ -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 %}} diff --git a/static/js/search.js b/static/js/search.js index ce07cf705f..895f3a7d2a 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -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) {