From d11e332dc692ba9c61ac0c0796a9c8e4e2431e51 Mon Sep 17 00:00:00 2001
From: Patrick Marsceill <patrick.marsceill@gmail.com>
Date: Fri, 16 Nov 2018 11:46:43 -0500
Subject: [PATCH] Create condition for no search and add config/css

---
 _config.yml                | 3 +++
 _includes/head.html        | 2 ++
 _layouts/default.html      | 6 ++++--
 _sass/layout.scss          | 7 ++++---
 _sass/navigation.scss      | 2 +-
 _sass/search.scss          | 2 +-
 assets/js/just-the-docs.js | 4 +++-
 7 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/_config.yml b/_config.yml
index 58d048a0..22aef3f2 100644
--- a/_config.yml
+++ b/_config.yml
@@ -21,6 +21,9 @@ baseurl: "/just-the-docs/" # the subpath of your site, e.g. /blog
 permalink: pretty
 exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "package.json", "script/", "LICENSE.txt", "lib/", "bin/", "README.md", "Rakefile"]
 
+# Enable or disable the site search
+search_enabled: true
+
 # Aux links for the upper right navigation
 aux_links:
   "Just the Docs on GitHub":
diff --git a/_includes/head.html b/_includes/head.html
index 8aae2cf9..cbd41f9d 100644
--- a/_includes/head.html
+++ b/_includes/head.html
@@ -4,7 +4,9 @@
 
   <title>{{ page.title }} - {{ site.title }}</title>
   <link rel="stylesheet" href="{{ "/assets/css/just-the-docs.css" | absolute_url }}">
+  {% if site.search_enabled != nil %}
   <script type="text/javascript" src="{{ "/assets/js/vendor/lunr.min.js" | absolute_url }}"></script>
+  {% endif %}
   <script type="text/javascript" src="{{ "/assets/js/just-the-docs.js" | absolute_url }}"></script>
 
   <meta name="viewport" content="width=device-width, initial-scale=1">
diff --git a/_layouts/default.html b/_layouts/default.html
index fe76346d..cc767863 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -16,7 +16,8 @@
     </div>
     <div class="main-content-wrap">
       <div class="page-header">
-        <div class="main-content pb-0">
+        <div class="main-content">
+          {% if site.search_enabled != nil %}
           <div class="search js-search">
             <div class="search-input-wrap">
               <input type="text" class="js-search-input search-input" placeholder="Search {{ site.title }}" aria-label="Search {{ site.title }}" autocomplete="off">
@@ -24,8 +25,9 @@
             </div>
             <div class="js-search-results search-results-wrap"></div>
           </div>
+          {% endif %}
           {% if site.aux_links != nil %}
-            <ul class="list-style-none text-small mt-md-2 pb-4 pb-md-0 js-aux-nav aux-nav">
+            <ul class="list-style-none text-small mt-md-1 mb-md-1 pb-4 pb-md-0 js-aux-nav aux-nav">
               {% for link in site.aux_links %}
                 <li class="d-inline-block my-0{% unless forloop.last %} mr-2{% endunless %}"><a href="{{ link.last }}">{{ link.first }}</a></li>
               {% endfor %}
diff --git a/_sass/layout.scss b/_sass/layout.scss
index e3c93e48..35b9631b 100644
--- a/_sass/layout.scss
+++ b/_sass/layout.scss
@@ -79,8 +79,6 @@
 
   @include mq(md) {
     background-color: $white;
-    border-bottom: $border $border-color;
-
   }
 
   .main-content {
@@ -88,8 +86,11 @@
 
     @include mq(md) {
       display: flex;
-      justify-content: space-between;
+      justify-content: flex-end;
+      height: 60px;
       padding-top: $sp-4;
+      padding-bottom: $sp-4;
+      border-bottom: $border $border-color;
     }
   }
 }
diff --git a/_sass/navigation.scss b/_sass/navigation.scss
index 0c7925cd..e5d580b0 100644
--- a/_sass/navigation.scss
+++ b/_sass/navigation.scss
@@ -14,7 +14,7 @@
     z-index: 101;
     height: 60px;
     padding-top: $sp-4;
-    box-shadow: inset 0 -1px 0 $border-color;
+    border-bottom: $border $border-color;
   }
 }
 
diff --git a/_sass/search.scss b/_sass/search.scss
index 70370806..7e3a8026 100644
--- a/_sass/search.scss
+++ b/_sass/search.scss
@@ -17,7 +17,7 @@
     display: block;
     padding-top: $sp-1;
     padding-right: 0;
-    padding-bottom: $sp-4;
+    padding-bottom: 0;
     padding-left: 0;
     margin-bottom: 0;
     background-color: transparent;
diff --git a/assets/js/just-the-docs.js b/assets/js/just-the-docs.js
index dd24cfc8..3c0a1b55 100644
--- a/assets/js/just-the-docs.js
+++ b/assets/js/just-the-docs.js
@@ -155,7 +155,9 @@ function initSearch() {
 
 function ready(){
   toggleNav();
-  initSearch();
+  if (typeof lunr !== 'undefined') {
+    initSearch();
+  }
 }
 
 // in case the document is already rendered
-- 
GitLab