nodenv / formulae

🏎 An online formulae browser for Homebrew
https://nodenv.github.io/formulae/
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Run our own Algolia docsearch #13

Closed jasonkarns closed 4 years ago

jasonkarns commented 4 years ago

In order to run our own docsearch, we need to point the snippet out our index with our apiKey. In order to do that, we need to allow customization of the configuration of that JS snippet.

The main homebrew snippet is "hardcoded" but not in the formulae.brew.sh site (of which this repo is a fork). The docsearch js snippet is hardcoded in the brew.sh repo here: https://github.com/Homebrew/brew.sh/blob/c10e8fc77a90659d1cce1384fff2edfae39a3a09/_layouts/base.html#L141-L150

So first, we needed to fork brew.sh's theme so that the values could be configured by sites rather then hardcoded. That was done here: https://github.com/Homebrew/brew.sh/blob/c10e8fc77a90659d1cce1384fff2edfae39a3a09/_layouts/base.html#L141-L150

That change makes the algolia configuration set via layout front matter, which can be inherited and overridden by other layouts (in particular, site layouts separate from the remote theme).

Once that was done, we needed to have all the templates within this site use a different base/default template that contained our customized algolia configuration in its front matter: https://github.com/nodenv/formulae/compare/master...nodenv:algolia-docsearch?expand=1#diff-be89cba44122f8374c18eb320a7cceb0

Then all the existing templates and pages were updated to point to our internal default template instead of the remote theme default or base or page.

(also, while we're here, we explicitly set the layout for .json pages to none as well as add a rake-run task for serving jekyll locally)

closes #1