Skip to content

taojunnan/vuepress-plugin-full-text-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuepress 中文全文搜索插件

代码来自https://github.com/leo-buneev/vuepress-plugin-fulltext-search,但是只支持英文全文搜索,做了部分改动

改动说明

  // ./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的卡顿

License

MIT

Releases

No releases published

Packages

No packages published