Description
We patch the Docusaurus SearchComponent
so that we can implement custom contextual optional facet filters in order to prefer user docs or contributor docs, depending whether the user is currently looking at user or contributor docs. This change was originally performed in #915 by using Docusaurus swizzle, but as of #1281 now we use a pnpm
patch applied to
the @docusaurus/theme-search-algolia
package (see bottom of root-level package.json
)
Unfortunately, this means that it is more challenging for us to upgrade Docusaurus.
Once Docusaurus supports custom contextual optional facet filters, we should stop patching. This page tracks the progress of that feature request.
Update:
On Docusaurus Discord, I got the following response
Hey, do you mean results would be preferred or restricted to the current context?
If restricted, you are on the right path as you can only retrieve results for the current
lvl0
with filtersIf preferred/re-ranked, we have some documentation about the custom ranking criteria here: https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/ otherwise you can apply some frontend sorting and re-order the results, you can do so by using the transformItems method: https://docsearch.algolia.com/docs/api#transformitems
Seems promising; will need to see if the items returned have enough info for us to do the re-ranking we want