Closed ykla closed 3 months ago
收到我看一下
是单独使用 这个插件遇到的问题吗?
vitepress-plugin-pagefind
{
"type": "module",
"license": "BSD-3-Clause",
"dependencies": {
"vitepress": "1.2.0",
"vite-plugin-vitepress-auto-nav": "2.3.2",
"markdown-it-footnote": "4.0.0",
"markdown-it-mathjax3": "4.3.2",
"markdown-it-task-checkbox": "1.0.6",
"vitepress-plugin-pagefind": "0.3.0",
"pagefind": "1.1.0"
},
"scripts": {
"docs:dev": "vitepress dev doc",
"docs:build": "vitepress build doc",
"docs:preview": "vitepress preview doc"
}
}
基本上是,我的文本量比较大,一开始使用 vitepress 官方自带插件可编译成功,但是无法使用,点击搜索不起作用。我已经在环境变量指定了 --max-old-space-size
参数,否则会 oom。再去掉 vitepress-plugin-pagefind
和 pagefind
后可正常编译运行。
vite-plugin-vitepress-auto-nav
是自动生成侧边栏的插件。见 https://github.com/Xaviw/vite-plugin-vitepress-auto-nav
本地无法编译的原因找到了,https://cn.vitejs.dev/guide/troubleshooting.html#requests-are-stalled-forever
修改后有解决你的问题吗。
本地无法编译的原因找到了,https://cn.vitejs.dev/guide/troubleshooting.html#requests-are-stalled-forever
修改后有解决你的问题吗。
未解决,因为这个只是本地无法编译(默认文件系统有限制)。GitHub Action 一直可以编译并且会有报错。
OK 我记一下,晚点拿你那个仓库我试一下
我也遇到了 ,可能是写bug 了。
可能不是这样,这个项目对于 vitepress 似乎看起来有些大了。即使是可能只有2000多个页面。我试过其他的官方文档的其他插件,都存在这些问题。他们是能编译出来,也有搜索框,但是搜索完全没反应。我一直在寻找优化的办法,但是还没有找到。如果你在编译的时候卡住了这可能是正常的(按照上面的链接解决文件系统的限制后),因为这个我本地 build 就一直过不去。CPU 会长时间 100%,可能是系统有问题,但是我使用的系统也是和 GitHub Action 一样的 24.04,各种软件版本也是一致的。但是 GitHub action 就能成功编译。
辛苦你使用最新的 vitepress-plugin-pagefind@0.3.3 再试试嘞,周末我更新了一下,解决了一那个构建阻塞的问题。
辛苦你使用最新的 vitepress-plugin-pagefind@0.3.3 再试试嘞,周末我更新了一下,解决了一那个构建阻塞的问题。
现在可以编译了,见https://taophilosophy.github.io/。但是所有搜索结果只有一条:#只有在构建后才生效 only support after build, only support after support
,目前 GitHub action 使用的已经是 build 了,辛苦再看看。
辛苦你使用最新的 vitepress-plugin-pagefind@0.3.3 再试试嘞,周末我更新了一下,解决了一那个构建阻塞的问题。
现在可以编译了,见https://taophilosophy.github.io/。但是所有搜索结果只有一条:
#只有在构建后才生效 only support after build, only support after support
,目前 GitHub action 使用的已经是 build 了,辛苦再看看。
我看了一下日志发现没有如预期的执行 pagefind,你看看在项目里把 pagefind 依赖装上,然后修改一下构建指令
① 装依赖
pnpm add pagefind
② 构建指令添加索引生成
{
"scripts": {
"docs:build": "vitepress build docs && npx pagefind --site docs/.vitepress/dist"
}
}
③插件配置改一下
pagefindPlugin({searchOptimization:false})
辛苦你使用最新的 vitepress-plugin-pagefind@0.3.3 再试试嘞,周末我更新了一下,解决了一那个构建阻塞的问题。
现在可以编译了,见https://taophilosophy.github.io/。但是所有搜索结果只有一条:
#只有在构建后才生效 only support after build, only support after support
,目前 GitHub action 使用的已经是 build 了,辛苦再看看。我看了一下日志发现没有如预期的执行 pagefind,你看看在项目里把 pagefind 依赖装上,然后修改一下构建指令
① 装依赖
pnpm add pagefind
② 构建指令添加索引生成
{ "scripts": { "docs:build": "vitepress build docs && npx pagefind --site docs/.vitepress/dist" } }
③插件配置改一下
pagefindPlugin({searchOptimization:false})
在配置后,生成的 pc 端页面搜索框无法点击。移动端可以点击,搜索结果是 #只有在构建后才生效 only support after build, only support after support
。已经去掉了我自己配置的多余的 CSS。麻烦有时间再看看。非常感谢你。
@ykla 迭代了一版,有空你再试试看
vitepress-plugin-pagefind@0.4.0
你好,本地测了一下,PC 界面无法点击搜框索。移动端可以点击,搜索结果是 #只有在构建后才生效 only support after build, only support after support。
{
"type": "module",
"license": "BSD-3-Clause",
"dependencies": {
"vitepress": "1.2.2",
"vite-plugin-vitepress-auto-nav": "2.3.2",
"markdown-it-footnote": "4.0.0",
"markdown-it-mathjax3-tao": "4.3.2",
"pagefind": "1.1.0",
"markdown-it-task-checkbox": "1.0.6",
"vitepress-plugin-pagefind": "0.4.0"
},
"trustedDependencies": [
"markdown-it-mathjax3-tao",
"vitepress-plugin-pagefind",
"esbuild",
"vue-demi"
],
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs && pagefind --site docs/.vitepress/dist",
"docs:preview": "vitepress preview docs",
"docs:serve": "vitepress serve docs --port 8080"
}
}
ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun install
bun install v1.1.12-canary.1 (43f0913c)
+ markdown-it-footnote@4.0.0
+ markdown-it-mathjax3-tao@4.3.2
+ markdown-it-task-checkbox@1.0.6
+ pagefind@1.1.0
+ vite-plugin-vitepress-auto-nav@2.3.2
+ vitepress@1.2.2
+ vitepress-plugin-pagefind@0.4.0
167 packages installed [2.99s]
ykla@ykla-ubuntu:~/taophilosophy.github.io$
ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun --bun run docs:build
$ vitepress build docs && pagefind --site docs/.vitepress/dist
vitepress v1.2.2
⠋ building client + server bundles...🎈 SUMMARY 解析中...
🎈 SUMMARY 解析完成...
⠸ building client + server bundles...🎈 SUMMARY 解析中...
🎈 SUMMARY 解析完成...
✓ building client + server bundles...
✓ rendering pages...
✓ generating sitemap...
build complete in 589.29s.
Running Pagefind v1.1.0 (Extended)
Running from: "/home/ykla/taophilosophy.github.io"
Source: "docs/.vitepress/dist"
Output: "docs/.vitepress/dist/pagefind"
[Walking source directory]
Found 2620 files matching **/*.{html}
[Parsing files]
Found a data-pagefind-body element on the site.
↳ Ignoring pages without this tag.
[Reading languages]
Discovered 1 language: zh-cn
[Building search indexes]
Total:
Indexed 1 language
Indexed 2619 pages
Indexed 232865 words
Indexed 0 filters
Indexed 0 sorts
Finished in 343.737 seconds
ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun --bun run docs:serve
$ vitepress serve docs --port 8080
vitepress v1.2.2
Built site served at http://localhost:8080/
^C
ykla@ykla-ubuntu:~/taophilosophy.github.io$
好滴,我看你截图里的日志 索引文件时正常生成了的 我看一下是不是哪块配置没对上
你看看你的构建产物里有这个目录吗?
你看看你的构建产物里有这个目录吗?
你好,有的。
ykla@ykla-ubuntu:~/taophilosophy.github.io/docs/.vitepress/dist$ ls
404.html e index.html o SUMMARY.html
a f j p t
assets favicon.ico k pagefind u
b g l q v
c guan-yu logo.svg qian-yan w
CODE_OF_CONDUCT.html h m r x
CONTRIBUTING.html hashmap.json mu-lu-s.html s y
d i n sitemap.xml z
ykla@ykla-ubuntu:~/taophilosophy.github.io/docs/.vitepress/dist$ du -h pagefind/
68M pagefind/fragment
70M pagefind/index
137M pagefind/
我估计是插件的 transformHead 钩子没有被执行.
你手动配一下可以,配置如下
import { defineConfig } from 'vitepress'
export default defineConfig({
head: [
[
'script',
{},
`import('/pagefind/pagefind.js')
.then((module) => {
window.__pagefind__ = module
module.init()
})
.catch(() => {
// console.log('not load /pagefind/pagefind.js')
})`
]
]
})
经过测试加上后可以搜索了。非常感谢。
回头这块 我出一个 SOP,针对插件内部分能力失效的地方
请问应该如何做才能看到具体的错误信息?项目地址 https://github.com/taophilosophy/taophilosophy.github.io。奇怪的是本地按同样版本的软件配置就会无限卡住,内存 CPU 都没有变化,只有 git action 会抛出上述错误。
Git action 见 https://github.com/taophilosophy/taophilosophy.github.io/blob/main/.github/workflows/deploy.yml
找了找只看到了 https://github.com/vitejs/vite/issues/13367
config.mts
: