summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-07-17 12:32:24 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-07-17 12:32:24 +0200
commitbe4957a05dfc36f870e608f119a878f911a4d48c (patch)
tree84c4b0e6604c7fc2bde045070cc98acf0e105c0f /assets/js
parent581ad2adf8536d20a0a37e6b2158aa6438a1a130 (diff)
downloadgohugo-theme-ed-be4957a05dfc36f870e608f119a878f911a4d48c.tar.gz
Set up the pipeline for indexing content in multiple languages
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/search.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/assets/js/search.js b/assets/js/search.js
index e964358..6cca4a5 100644
--- a/assets/js/search.js
+++ b/assets/js/search.js
@@ -12,13 +12,26 @@ async function initSearchIndex() {
// Create the lunr index for the search
searchIndex = lunr(function () { // eslint-disable-line no-undef
- this.use(lunr.multiLanguage('de', 'en', 'es', 'fr', 'it', 'pt', 'ru')); // eslint-disable-line no-undef
+ // Set up the pipeline for indexing content in multiple languages
+ if (Array.isArray(searchConfig.lunrLanguages)) {
+ // Lunr has full support for the indexing and searching of
+ // documents in English. So no need add 'en'.
+ let langs = searchConfig.lunrLanguages.slice();
+ langs = langs.filter(lang => lang !== 'en');
+
+ const pipeline = lunr.multiLanguage( // eslint-disable-line no-undef
+ ...langs
+ );
+
+ this.use(pipeline);
+ }
this.field('objectID');
this.field('title');
this.field('categories');
this.field('tags');
this.field('content');
+
this.ref('href');
pagesIndex.forEach((page) => this.add(page));