Skip to content

Commit

Permalink
Add mkdocs search hack.
Browse files Browse the repository at this point in the history
Should close #3376.

Copy-Pasta from nodemcu/nodemcu-firmware@7dd89dd.
  • Loading branch information
decentral1se authored and borsboom committed Sep 4, 2017
1 parent 952123f commit 32dd4c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Bug fixes:
trust the etag and not re-download. Fixed in this version.
* Invoking `stack --docker` in parallel now correctly locks the sqlite database.
See [#3400](https://github.com/commercialhaskell/stack/issues/3400).
* docs.haskellstack.org RTD documentation search is replaced by the mkdocs
search. Please see
[#3376](https://github.com/commercialhaskell/stack/issues/3376).


## 1.5.1

Expand Down
29 changes: 29 additions & 0 deletions etc/mkdocsjs/searchhack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Please see https://github.com/commercialhaskell/stack/issues/3376

(function () {
$(document).ready(function () {
fixSearch();
});

function fixSearch() {
var target = document.getElementById('rtd-search-form');
var config = {attributes: true, childList: true};

var observer = new MutationObserver(function(mutations) {
observer.disconnect();
var form = $('#rtd-search-form');
form.empty();
form.attr('action', 'https://' + window.location.hostname + '/en/' + determineSelectedBranch() + '/search.html');
$('<input>').attr({
type: "text",
name: "q",
placeholder: "Search docs"
}).appendTo(form);
});

if (window.location.origin.indexOf('readthedocs') > -1) {
observer.observe(target, config);
}
}

})();
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ pages:
markdown_extensions:
- toc:
permalink: true

extra_javascript:
- etc/mkdocsjs/searchhack.js

0 comments on commit 32dd4c4

Please sign in to comment.