New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Lunr pre-built indexes #1396
Comments
Thanks for submitting this issue @mgroeber9110, and apologies for the delay - has been hard for me to find OSS time this quarter! I appreciate you writing up this issue. I haven't personally used a site with such a large search index, but I'm sure that you aren't the only use-case (e.g. I'm aware of other client sites that have that size - many of which are not open-source). Something to be aware of is that many of our users use the
I will think on this some more. However, if you are interested in contributing a solution, I'd be happy to work with you on a PR! Let me know what your thoughts are. An interesting related feature is #1068. It may provide prior art for how to name this feature, and we need to make sure that both play together nicely! |
Not yet sure if/when I will get around to trying an implementation yet, but here are a few notes on what I have found out so far:
My naive understanding was that Github Actions are required in any case to apply this theme (just from looking at the template), but this probably neglects its use in other CI environments. Of course, the easiest fallback might be to just not pre-build the index if not all dependencies are available and to only treat this as an optional speedup... |
Thanks for the quick response @mgroeber9110! I had a chance to do a bit more digging, and mkdocs default search plugin actually behaves quite similarly to your proposed issue: it uses Node to pre-build the index and assumes that it's a part of the user's build system. It's opt-in, and they expect users opting-in to it to know that they need to properly configure While this seems a bit brittle to me, this does provide prior art for your original issue. So, with that in mind, I think that could be a reasonable path forward - no need to implement a native In other words,
Sounds like a great idea 😊 @pdmosses any thoughts on this matter? You've had great insights on things I've missed before! |
I have used JTD to convert a relatively large collection of pre-existing Markdown docs into a site deployed onto gh-pages (after having previously used the
jekyll-build-pages
action). While the conversion overall works fairly well (after installing a few additional plugins thatjekyll-build-pages
includes by default, such as supporting Markdown without Front Matter).The resulting documentation can be found here: https://bluewaysw.github.io/pcgeos
The Markdown documentation is about 11 MB in size, leading to a
search-data.json
size for lunr full-text-search of about 6 MB. This causes noticeable freezes in the page after loading, while lunr generates its index.The lunr docs describe a solution for pre-building indexes, which appears to be relatively straightforward to integrate into just-the-docs:
Add support for an optional file
search-index.json
that is loaded together withsearch-data.json
. If loading t´he index file fails, the onload event generates the index locally, otherwise it just loads the index JSON.For generating the index, a file
build-index.json
is put into the assets that can be called via node.js if desired:node build-index.js < _site\assets\js\search-data.json > _site\assets\js\search-index.json
This could for example happen in a github action after generating the site. The
build-index.js
could look something like this:For our site, the index would be about 11 MB in size. I have not yet fully integrated this approach, but if this looks feasible, I could try making a PR for it.
The text was updated successfully, but these errors were encountered: