docs icon indicating copy to clipboard operation
docs copied to clipboard

Add search

Open lsf37 opened this issue 5 months ago • 3 comments

In the docsite redesign we removed the duckduckgo search bar. The plan is to replace it with a custom search bar.

Current ideas for this are roughly

  • use something like elasticlunr
  • produce an index by scanning the generated _site, focussing the search on the <main>, <title>, and <h*> tags with more weight on <h*> and <title>
  • it would be nice to recognise API functions and give them more weight so that it is possible to go to them quickly. Not sure how much work that would be.
  • write js to present search results in a reasonably nice form (examples would be mdbook or the search on the tailwindcss.com site)
  • make sure search can be operated by keyboard without mouse

lsf37 avatar Jul 17 '25 00:07 lsf37

The main problem is that you either have to load all pages (or an index) in one big blob, to have the full context, or you need a server side component like node.js or whatever, which won't work for a static site. This is definitely one of those things that seems easy, but is hard to get right.

Indanz avatar Jul 17 '25 10:07 Indanz

Yes, the plan is to generate an index offline and load it separately (asynchronously) so that it is at least cached and not duplicated on each page. Unlikely to be quick and easy, I agree.

lsf37 avatar Jul 20 '25 23:07 lsf37

That wouldn't be too bad, loading only on demand with Javascript when people do an actual search. You could then also split up the index into multiple files. That should be doable and give decent results.

Indanz avatar Jul 21 '25 08:07 Indanz