emersonbottero / vitepress-plugin-search

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

Invalid hashes from parsed md files #22

Closed pdanpdan closed 1 year ago

pdanpdan commented 1 year ago

Hello.

It looks like in here only spaces are converted to dashes, but vitepress also removes a lot of not alphanumeric chars: https://github.com/emersonbottero/vitepress-plugin-search/blob/74c5dda95db1a157353e732ea55fadee3bd86164/src/Search.vue#L44

link = link.split(" ").join("-");

can be replaced with

link = link.split( "#" );
link = link[0] + (typeof link[1] === "string" ? '#' + link[1].split(" ").join("-").split(/[^a-z0-9_-]+/i).join("") : "");
IsLand-x commented 1 year ago

Maybe it will be better if the markdown-it options and flexsearch options can both be configured by user. Then you can modify the links(custom slugify) and do more custom operations

I've tried to make a pr but unfortunately I cannot setup this project properly :(

emersonbottero commented 1 year ago

fixed in last version