From 3b24964565b7b59ef6602ea92ea03b79e26b0682 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Mon, 4 Sep 2017 08:49:47 -0700 Subject: [PATCH] Fix mkdocs search hack. --- {etc/mkdocsjs => doc/js}/searchhack.js | 4 ++-- mkdocs.yml | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) rename {etc/mkdocsjs => doc/js}/searchhack.js (74%) diff --git a/etc/mkdocsjs/searchhack.js b/doc/js/searchhack.js similarity index 74% rename from etc/mkdocsjs/searchhack.js rename to doc/js/searchhack.js index 03608c2163..d68f932859 100644 --- a/etc/mkdocsjs/searchhack.js +++ b/doc/js/searchhack.js @@ -13,7 +13,7 @@ observer.disconnect(); var form = $('#rtd-search-form'); form.empty(); - form.attr('action', 'https://' + window.location.hostname + '/en/' + determineSelectedBranch() + '/search.html'); + form.attr('action', 'https://' + window.location.hostname + '/' + window.location.pathname.split('/')[1] + '/' + window.location.pathname.split('/')[2] + '/search.html'); $('').attr({ type: "text", name: "q", @@ -21,7 +21,7 @@ }).appendTo(form); }); - if (window.location.origin.indexOf('readthedocs') > -1) { + if (window.location.origin.indexOf('readthedocs') > -1 || window.location.origin.indexOf('docs.haskellstack') > -1) { observer.observe(target, config); } } diff --git a/mkdocs.yml b/mkdocs.yml index d615e4450f..eb329a993d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,6 +8,8 @@ site_dir: _site theme: readthedocs extra_css: - css/extra.css +extra_javascript: +- js/searchhack.js pages: - Home: README.md @@ -38,6 +40,3 @@ pages: markdown_extensions: - toc: permalink: true - -extra_javascript: -- etc/mkdocsjs/searchhack.js