diff --git a/package.json b/package.json index c4bbd5cd96..cc589a7c3c 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "prepare": "husky" }, "dependencies": { + "@node-rs/jieba": "^1.7.2", "cheerio": "^0.22.0", "hexo": "^7.0.0", "hexo-clean-css": "^2.0.0", @@ -25,6 +26,7 @@ "hexo-tag-embed": "^1.0.0-rc.1", "hexo-uglify": "^2.0.0", "lunr": "2.3.9", + "lunr-languages": "^1.14.0", "sharp": "^0.33.1" }, "devDependencies": { diff --git a/scripts/helpers.js b/scripts/helpers.js index 1d082fc54b..4cf27e7a1c 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -5,6 +5,9 @@ const { basename } = require('path'); const cheerio = require('cheerio'); const lunr = require('lunr'); +require('lunr-languages/lunr.stemmer.support.js')(lunr); +require('lunr-languages/lunr.zh.js')(lunr); +require('lunr-languages/lunr.multi.js')(lunr); const full_url_for = hexo.extend.helper.get('full_url_for').bind(hexo); const localizedPath = ['docs', 'api']; @@ -151,6 +154,7 @@ hexo.extend.helper.register('plugin_list', function() { hexo.extend.helper.register('lunr_index', data => { const index = lunr(function() { + this.use(lunr.multiLanguage('en', 'zh')); this.field('name', {boost: 10}); this.field('tags', {boost: 50}); this.field('description'); diff --git a/themes/navy/layout/partial/after_footer.njk b/themes/navy/layout/partial/after_footer.njk index 55750cda29..af0b54d64b 100644 --- a/themes/navy/layout/partial/after_footer.njk +++ b/themes/navy/layout/partial/after_footer.njk @@ -8,6 +8,8 @@ {% if page.layout === 'plugins' %} + +