DocSearch's `transformData` function cannot remove hashes from result URLs

Hi! I’m using DocSearch on a VuePress site with a manual scraper.

If a search result returns a URL with a particular hash in it (e.g., http://myurl.com/#main), I want like to remove the hash entirely from the search result (e.g., http://myurl.com).

I’ve tried using the transformData function to accomplish this, but it seems DocSearch will not allow me to completely remove the hash from the result URL.

I’ve worked up an example over on JSFiddle to show what’s happening.

Anyone have any ideas about how to get around this?

Hi Leslie, the url is rebuilt in the hit template so if you don’t want to have the anchor you could set it to null if it exists in your transformData map.

Could look like this: https://jsfiddle.net/Kevin_Granger/xon87Luc/12/

Hope it helps

Super helpful, thank you @kevin.granger! This answered my question.

Cheers!

1 Like