emersonbottero / vitepress-plugin-search

Provide local search to your documentation site.
MIT License
238 stars 30 forks source link

Support filtering? #37

Closed xxllxhdj closed 1 year ago

xxllxhdj commented 1 year ago

Now all .md files under the root directory of the docs project are indexed, including node_modules folder. Can you support filtering, such as include and exclude?

emersonbottero commented 1 year ago

All examples I saw placed the files in an subfolder like docs.. but I guess we have the option to use the root as source.. but then.. won't vitepress be looking for all files including node_modules?

can you check if it will render /node_module/path_to_an_know_md_file in the browser and see if it renders?

using .gitignore would make sense in this case?

xxllxhdj commented 1 year ago

Yes, I place the files in docs folder, and there is package.json file in this folder, like this: --docs ----.vitepress ----node_modules ----index.md ----package.json Then the .md files in this node_modules can be indexed.

using .gitignore can't work..

emersonbottero commented 1 year ago

you don't need to make the package.json inside docs.. it does not make sense in this case.. 😅 is there any reason for that?

xxllxhdj commented 1 year ago

We regard the docs as a stand-alone project, so it should have its own package.json instead of sharing with the main project.

emersonbottero commented 1 year ago

I think it would be best to create an issue in vitepress first, you can reference this one. I intercept all MD files vitepress uses.. There should be a way to filter folder in vitepress itself first. This plugin would naturally work as expected once you do that.

Could you open one there?

xxllxhdj commented 1 year ago

Actually vitepress don't use the md files of docs/node_modules in my case. From this source code, it seems to have nothing to do with vitepress. Just the root directory configuration is used..

emersonbottero commented 1 year ago

Actually vitepress don't use the md files of docs/node_modules in my case. From this source code, it seems to have nothing to do with vitepress. Just the root directory configuration is used..

The parameter passed in this method is the same one from vitepress config.

P.S: I tested and vitepress does indeed use it...

xxllxhdj commented 1 year ago

But vitepress ignores node_modules by default, and supports srcExclude option. Refer to this code snippet.

According to the above discussion, should it be same with vitepress?

emersonbottero commented 1 year ago

But vitepress ignores node_modules by default, and supports srcExclude option. Refer to this code snippet.

According to the above discussion, should it be same with vitepress?

now this method exclude node_modules from the page data ... It is still processing the md files..

if you can search something that is inside no_modules and you can click in the results it goes to that page it is processing that page iside node_modules

Edit: it is processed in dev but not in build...

I'll filter node_modules by default then... I'll try get the data from exclusionDir also