Skip to content

Commit

Permalink
feat: 搜索插件使用 jieba 分词,尝试提升搜索体验 (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAnotherID authored Feb 11, 2024
1 parent c9e47f2 commit 1f556ab
Show file tree
Hide file tree
Showing 3 changed files with 673 additions and 43 deletions.
6 changes: 6 additions & 0 deletions docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerComponentsPlugin } from "@vuepress/plugin-register-components";
// @ts-ignore
import { searchProPlugin } from "vuepress-plugin-search-pro";
import { path } from "@vuepress/utils";
import { cut } from "nodejs-jieba";

import theme from "./theme";

Expand All @@ -25,6 +26,11 @@ export default defineUserConfig({
searchProPlugin({
indexContent: true,
autoSuggestions: true,
indexOptions: {
// 使用 jieba 分词
tokenize: (text, fieldName) =>
fieldName === "id" ? [text] : cut(text, true),
},
}),
],
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
"vuepress-plugin-md-enhance": "2.0.0-beta.245",
"vuepress-plugin-search-pro": "2.0.0-beta.245",
"vuepress-theme-hope": "2.0.0-beta.245"
},
"dependencies": {
"nodejs-jieba": "^0.1.2"
}
}
Loading

0 comments on commit 1f556ab

Please sign in to comment.