From 8851faacfce060b280a6d2e3db41e7db423dfe40 Mon Sep 17 00:00:00 2001 From: Egliss <37934691+Egliss@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:52:01 +0900 Subject: [PATCH] Fix japanese search (#9605) * Fix japanease tinyseg deps * Refactor import target suffix * lint --------- Co-authored-by: Yufei Huang --- templates/modern/src/search-worker.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/modern/src/search-worker.ts b/templates/modern/src/search-worker.ts index fe62c6dba9e..acaeee140c4 100644 --- a/templates/modern/src/search-worker.ts +++ b/templates/modern/src/search-worker.ts @@ -3,6 +3,7 @@ import lunr from 'lunr' import stemmer from 'lunr-languages/lunr.stemmer.support' +import tinyseg from 'lunr-languages/tinyseg' import multi from 'lunr-languages/lunr.multi' import { get, set, createStore } from 'idb-keyval' @@ -28,6 +29,9 @@ async function loadIndex({ lunrLanguages }: { lunrLanguages?: string[] }) { if (lunrLanguages && lunrLanguages.length > 0) { multi(lunr) stemmer(lunr) + if (lunrLanguages.includes('ja')) { + tinyseg(lunr) + } await Promise.all(lunrLanguages.map(initLanguage)) }