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 30207ac
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,18 @@ Bug fixes:
See [#3366](https://github.com/commercialhaskell/stack/pull/3366).
* `stack script` can now handle relative paths to source files.
See [#3372](https://github.com/commercialhaskell/stack/issues/3372).
<<<<<<< HEAD
* Fixes explanation of why a target is needed by the build plan, when the
target is an extra dependency from the commandline.
See [#3378](https://github.com/commercialhaskell/stack/issues/3378).
* Previously, if you delete a yaml file from ~/.stack/build-plan, it would
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 30207ac

Please sign in to comment.