vitepress-plugin-pagefind: v0.4.4 breaks rendering
slusarz opened this issue · 8 comments
b47b213 introduced this code:
if (!code.includes(options?.ssr ? '_push(`' : '_createElementBlock("div", null')) {
// ...
return code.replace('_createElementBlock("div", null', `_createElementBlock("div", ${stringify(attrs)}`)
This code assumes the Vue rendering code is of the format _createElementBlock("div", null, [ ... ])
.
However, on out system, the rendering code is simply outputting a single, empty DIV tag. This uses the simplified function signature _createElementBlock("div")
. Example:
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return (_openBlock(), _createElementBlock("div"))
}
This results in every page issuing this warning:
[plugin:vitepress-plugin-pagefind] [plugin vitepress-plugin-pagefind] docs/core/admin/index.md: Client /foo/docs/core/admin/index.md may not be a valid file, will not be indexed, please contact the author for assistance
And the second replace call fails.
Solution: Replace code needs to check for both function signatures.
Sure, thank you for the feedback. I will work on it in the next two days. In the meantime, you can revert back to the previous version and use 0.4.3.
Can you provide a demo? I'll try to reproduce it. Is this related to the VitePress version?
Our installation should be up-to-date, using VitePress 1.2.3:
https://github.com/dovecot/documentation/blob/ced4a60d804d414dc2c1dec56e0745aab16fbbac/package.json
I don't think we're doing anything too crazy with the config either:
https://github.com/dovecot/documentation/blob/ced4a60d804d414dc2c1dec56e0745aab16fbbac/.vitepress/config.js
Running npm run docs:build
command. Dump of the code
variable in the transform()
function gives:
export const __pageData = JSON.parse("{\"title\":\"Administration\",\"description\":\"\",\"frontmatter\":{\"title\":\"Administration\",\"exclude\":true,\"order\":110},\"headers\":[],\"relativePath\":\"core/admin/index.md\",\"filePath\":\"core/admin/index.md\",\"lastUpdated\":1719485127000}")
const _sfc_main = {name:"core/admin/index.md"}
import { openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return (_openBlock(), _createElementBlock("div"))
}
import _export_sfc from 'plugin-vue:export-helper'
export default /*#__PURE__*/_export_sfc(_sfc_main, [['render',_sfc_render]])
Ah, yes, that's probably a bit unique to our setup as we use an auto sidebar generator, where these empty MD files are used to insert/configure sidebar stuff without creating an actual page.
Thanks for tracking this down.
Does that mean that it's possible not to index those pages without content?
There's nothing to index, so I would have no problem with the pagefind plugin code just skipping that page.
you can try vitepress-plugin-pagefind@0.4.5