- Docusaurus (kuizuo-blog) 当前是 Algolia 搜索,想切换成 docusaurus-search-local 搜索。
- Algolia 好像看我不活跃 发邮件
Your suspended application will be removed in 2 days.
,弄过一次,过了几个月又报这个,直接换成本地检索好了。 - 本地检索不支持句子中的中文,只能直接搜索一段话,并 不是特别好用。
- 列如:
我最近用的版本:aaabbb
- 搜索
版本
是搜索不到这句的 - 搜索
我最近用的版本
才搜索到对应的这篇文章。
- 搜索
- 列如:
- 需要安装 结巴分词 jieba
- Algolia 好像看我不活跃 发邮件
安装
pnpm i
pnpm i @cmfcmf/docusaurus-search-local
pnpm i @node-rs/jieba
修改
vim docusaurus.config.ts
module.exports = {
// ...
themeConfig: {
// ⭐ 注释掉 algolia 的配置
// algolia: {
// appId: 'aaaa',
// apiKey: 'bbbb',
// indexName: 'index_name',
// },
}
// ...
plugins: [require.resolve("@cmfcmf/docusaurus-search-local")],
// or, if you want to specify options:
// ...
plugins: [
[
require.resolve("@cmfcmf/docusaurus-search-local"),
{
// Options here
// ⭐ 增加中文配置
language: ['en', 'zh'],
},
],
],
};
启动
pnpm run
github 上说直接启动不会开启搜索- 需要 build serve 才行
npm run docusaurus build
npm run docusaurus serve
报错
安装 nodejieba 报错
- 已经改包 名为 node-rs/jieba
- pnpm i @node-rs/jieba
(base) PS D:\CodeProjects\anguswg.github.io> pnpm install nodejieba@^2.5.0
WARN deprecated loadsh@0.0.4: This is a typosquat on the popular Lodash package. This is not maintained nor is the original Lodash package.
WARN 22 deprecated subdependencies found: are-we-there-yet@2.0.0, gauge@3.0.2, npmlog@5.0.1, rollup-plugin-terser@7.0.2, sourcemap-codec@1.4.8, stable@0.1.8, workbox-background-sync@6.6.1, workbox-broadcast-update@6.6.1, workbox-build@6.6.1, workbox-cacheable-response@6.6.1, workbox-core@6.6.1, workbox-expiration@6.6.1, workbox-google-analytics@6.6.1, workbox-navigation-preload@6.6.1, workbox-precaching@6.6.1, workbox-range-requests@6.6.1, workbox-recipes@6.6.1, workbox-routing@6.6.1, workbox-strategies@6.6.1, workbox-streams@6.6.1, workbox-sw@6.6.1, workbox-window@6.6.1
Packages: +30 -1
++++++++++++++++++++++++++++++-
Progress: resolved 1524, reused 1523, downloaded 0, added 0, done
node_modules/.pnpm/nodejieba@2.6.0/node_modules/nodejieba: Running install script, failed in 1.9s
.../node_modules/nodejieba install$ node-pre-gyp install --fallback-to-build
│ node-pre-gyp info it worked if it ends with ok
│ node-pre-gyp info using node-pre-gyp@1.0.11
│ node-pre-gyp info using node@20.10.0 | win32 | x64
│ node-pre-gyp info check checked for "D:\CodeProjects\anguswg.github.io\node_modules\.pnpm\nodejieba@2.6.0\node_modules\nodejieba\build\Releas…
│ node-pre-gyp http GET https://github.com/yanyiwu/nodejieba/releases/download/v2.6.0/nodejieba-v2.6.0-node-v115-win32-x64.tar.gz
│ node-pre-gyp ERR! install response status 404 Not Found on https://github.com/yanyiwu/nodejieba/releases/download/v2.6.0/nodejieba-v2.6.0-nod…
│ node-pre-gyp WARN Pre-built binaries not installable for nodejieba@2.6.0 and node@20.10.0 (node-v115 ABI, unknown) (falling back to source co…
│ node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/yanyiwu/nodejieba/releases/download/v2.6.0/nodejieba-v2.6.0-n…
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@9.4.1
│ gyp info using node@20.10.0 | win32 | x64
│ gyp info ok
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@9.4.1
│ gyp info using node@20.10.0 | win32 | x64
│ gyp info find Python using Python version 3.10.13 found at "D:\ProgramData\miniconda3\python.exe"
│ gyp ERR! find VS
│ gyp ERR! find VS msvs_version not set from command line or npm config
│ gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
│ gyp ERR! find VS checking VS2022 (17.6.33829.357) found at:
│ gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
│ gyp ERR! find VS - found "Visual Studio C++ core features"
│ gyp ERR! find VS - missing any VC++ toolset
│ gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use