Experiment with pagefind for search#55
Conversation
…and theme it according to our existing light/dark themes.
|
I'm a little confused by the intent of this PR I just want to be sure I understand:
Either way I need to get back into the website and docs so I'll be having a proper look at this. |
I started out just wanting to play around with this… and then thought the results were so good that it warranted feedback from others on whether it was good enough to ship. I figured it was possible @confused-Techie might've preferred it to what they'd been working on. I think it's good enough to ship, but wouldn't want to do so without @confused-Techie’s feedback first (not trying to step on toes!). |
Yeah, this is technically a bug in the |
There is one way of fixing this that would be pretty ridiculous, but it's at least possible:
So we could generate three different versions of the docs site search index — one for each platform — and could use the Pretty silly, but (a) it takes less than a second to generate a single index; (b) this problem will be present no matter which solution we pursue, so even a silly fix might be worth it! |
It was just something I threw together, so it can certainly be improved. (But it does literally use theme colors!) |
This might eventually be solved by building different indexes for the API docs and the narrative docs, then selectively deciding whether to merge them together based on context. (I don't know yet whether a keyword like |
Agree, it is certainly an improvement over no search at all and it seems to work - all my comments are relatively minor. It sounds like generating multiple indices would solve a few issues so if it isn't going to cause significant problems then I'd say go for it.
Honestly I think its only really the tweak to the padding for the overlap issue but the colours, I'm guess I mean in terms of "brand" themeing as it seems the colour is the
|
…on the theory that it's our most popular platform and not much of value will be lost.
…so that they show up as such in the search results. This also contextualizes the ordinary page titles of API documentation pages.
We don't have existing colors like that in the shared theme across our three sites (main, blog, docs), so I'll invent one. |







It might seem like this PR’s existence implies that I think #43 is lacking in some way. Not at all; I was just compelled to try out Pagefind and was pleasantly surprised at how well it solved this problem.
Here's what this PR does:
npm run buildornpm run serve) also regenerates the search index (which is incredibly fast)I was also gratified that I managed to get this done without sprinkling any of Pagefind’s custom data attributes throughout the HTML. They say this is the “preferred” way of opting into indexing of certain pages and opting out of indexing others, but I was determined to avoid it if it could be helped. (Instead, I use CSS selectors to exclude certain portions of each page from being indexed, and use a silly glob to ensure only the latest API docs are indexed).
I owe a review of #43, so I'll get to that soon. But if we run into any snags with the search service, we might want to deploy this version as a stopgap, since it's better than having no search capability whatsoever!