vuepress plugin full text search
1.0.0
代碼來自https://github.com/leo-buneev/vuepress-plugin-fulltext-search,但是只支持英文全文搜索,做了部分改動
修改flexsearch默認配置
使用中文分詞模塊segmentit
// ./services/flexsearchSvc.js
// flexsearch 默认配置的修改, 以及引入中文分词模块
let defaultOptions = {
encode : false ,
async : true ,
tokenize : function ( str ) {
var result = segmentit . doSegment ( str , {
simple : true
} ) ;
return result ;
}
} 把整體代碼拷貝到vuepress項目目錄下,如
.
├─ docs
├─ myPlugins
│ └─ fullSearchBox // 当前插件所在文件夹
└─ package.json
在config.js中引用該插件
plugins: [
require . resolve ( '../../myPlugins/fullSearchBox/' )
]在package.json中加入以下依賴
"devDependencies" : {
"flexsearch" : " nextapps-de/flexsearch " ,
"html-to-text" : " ^5.1.1 " ,
"segmentit" : " ^2.0.3 " ,
}安裝依賴
npm i
運行
加載segment詞典會有1 - 2s的卡頓
MIT