leo-buneev / vuepress-plugin-fulltext-search

Adds full-text search capabilities to your vuepress site with a help of flexsearch library.
MIT License
93 stars 23 forks source link

Improve error messages for empty pages #15

Closed uempfel closed 3 years ago

uempfel commented 3 years ago

Hi,

first of all, thanks for sharing the plugin. It works great and solves a big issue for us.

Error Message

We recently encountered the following error message when building our site:

Error when applying fulltext-search plugin: Error: Input data should be a String
    at MarkdownIt.parse (/home/basti/programming/rz20/customerjourney/node_modules/markdown-it/lib/index.js:518:11)
    at MarkdownIt.render (/home/basti/programming/rz20/customerjourney/node_modules/markdown-it/lib/index.js:543:36)
    at MarkdownIt.md.render.args [as render] (/home/basti/programming/rz20/customerjourney/node_modules/@vuepress/markdown/index.js:141:25)
    at extendPageData (/home/basti/programming/rz20/customerjourney/node_modules/vuepress-plugin-fulltext-search/index.js:7:48)
    at Promise.all.enhancers.map (/home/basti/programming/rz20/customerjourney/node_modules/@vuepress/core/lib/node/Page.js:293:19)
    at Array.map (<anonymous>)
    at Page.enhance (/home/basti/programming/rz20/customerjourney/node_modules/@vuepress/core/lib/node/Page.js:290:17)
    at Page.process (/home/basti/programming/rz20/customerjourney/node_modules/@vuepress/core/lib/node/Page.js:148:16)

Although the build didn't break, the search function failed to work.

Reason for the Error

It turns out that we included an empty page in our VuePress document by adding a reference to a blank .md file to config.js.

It would be great if we could get a more precise error message in cases like that. It should include a link to the .md file that causes the plugin to fail.

Versions used

leo-buneev commented 3 years ago

Resolved in 2.0.4 - empty pages shouldn't throw errors anymore

uempfel commented 3 years ago

Thank you @leo-buneev, appreciate it!