Closed arcqiufeng closed 1 year ago
my full code:
// docs/vite.config.ts
// 原 https://registry.yarnpkg.com 连接似乎有问题
// 切换到 https://registry.npmmirror.com/ 淘宝的试试
// yarn config set registry https://registry.npmmirror.com/
// yarn add vitepress-plugin-search markdown-it flexsearch -D
import { SearchPlugin } from "vitepress-plugin-search";
import { defineConfig } from "vite";
// 分词器来源
// https://wenjiangs.com/article/segment.html
// https://github.com/leizongmin/node-segment
// 安装:
// yarn add segment -D
// 以下为样例
// 载入模块
var Segment = require('segment');
// 创建实例
var segment = new Segment();
// 使用默认的识别模块及字典,载入字典文件需要1秒,仅初始化时执行一次即可
segment.useDefault();
// 开始分词
// console.log(segment.doSegment('这是一个基于Node.js的中文分词模块。'));
var options = {
// 采用分词器优化,
encode: function (str) {
return segment.doSegment(str, {simple: true});
},
tokenize: "full",
// 以下代码返回完美的结果,但内存与空间消耗巨大,索引文件达到80M+
// encode: false,
// tokenize: "full", // 解决汉字搜索问题。来源:https://github.com/emersonbottero/vitepress-plugin-search/issues/11
};
export default defineConfig({
plugins: [SearchPlugin(options)],
});
Finally I deleted all other files and folders but the docs
folder.
Then I re-initialize all the VitePress environment by the following sequence.
yarn add -D vitepress
npx vitepress init
yarn add -D markdown-it-mathjax3
yarn add -D markdown-it-footnote
yarn add -D markdown-it-multimd-table
yarn add -D markdown-it-mark
yarn add -D markdown-it-sub
yarn add -D markdown-it-sup
yarn add -D medium-zoom
yarn add -D vitepress-plugin-search
yarn add -D segment
Then I tried this:
yarn docs:dev
Got the error message: package vite
not found.
Then I change the code:
import { defineConfig } from "vite";
to:
import { defineConfig } from "vitepress";
Now it works.
Hi, after recent vitepress (alpha50) update, I cannot search anymore via this plugin.
I just cannot type any words in the searchbox.
Anyone had the same problem as me?