From 132cecfea3ba2dbdcf37ac519390175d713edd4b Mon Sep 17 00:00:00 2001
From: Silvio Giebl <silvio.giebl@hivemq.com>
Date: Sat, 17 Aug 2019 14:32:25 +0200
Subject: [PATCH] Added logo variable to _config.yml which can be set to a
 path/url Automatically replaces the title with a logo

---
 _config.yml                       |  1 +
 _includes/title.html              |  6 +++++-
 _sass/layout.scss                 | 11 +++++++++++
 assets/css/dark-mode-preview.scss |  4 ++++
 assets/css/just-the-docs.scss     |  4 ++++
 5 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/_config.yml b/_config.yml
index d12d4396..60b446d2 100644
--- a/_config.yml
+++ b/_config.yml
@@ -17,6 +17,7 @@ title: Just the Docs
 description: A Jekyll theme for documentation
 baseurl: "/just-the-docs" # the subpath of your site, e.g. /blog
 url: "https://pmarsceill.github.io" # the base hostname & protocol for your site, e.g. http://example.com
+#logo: "/assets/images/just-the-docs.png"
 
 permalink: pretty
 exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "package.json", "package-lock.json",  "script/", "LICENSE.txt", "lib/", "bin/", "README.md", "Rakefile"]
diff --git a/_includes/title.html b/_includes/title.html
index f6d56693..8bd3fa83 100644
--- a/_includes/title.html
+++ b/_includes/title.html
@@ -1 +1,5 @@
-{{ site.title }}
\ No newline at end of file
+{% if site.logo %}
+  <div class="site-logo"></div>
+{% else %}
+  {{ site.title }}
+{% endif %}
diff --git a/_sass/layout.scss b/_sass/layout.scss
index d826cfc5..9ec8b077 100644
--- a/_sass/layout.scss
+++ b/_sass/layout.scss
@@ -153,6 +153,17 @@
   }
 }
 
+@if variable-exists(logo) {
+  .site-logo {
+    width: 100%;
+    height: 100%;
+    background-image: url($logo);
+    background-position: left center;
+    background-repeat: no-repeat;
+    background-size: contain;
+  }
+}
+
 .menu-button {
   appearance: none;
   display: flex;
diff --git a/assets/css/dark-mode-preview.scss b/assets/css/dark-mode-preview.scss
index 8b77da6a..c524e812 100644
--- a/assets/css/dark-mode-preview.scss
+++ b/assets/css/dark-mode-preview.scss
@@ -3,6 +3,10 @@
 # only Main files contain this front matter, not partials.
 ---
 
+{% if site.logo %}
+$logo: "{{ site.logo | absolute_url }}";
+{% endif %}
+
 //
 // Import external dependencies
 //
diff --git a/assets/css/just-the-docs.scss b/assets/css/just-the-docs.scss
index 6a2eefa5..57d03aa3 100644
--- a/assets/css/just-the-docs.scss
+++ b/assets/css/just-the-docs.scss
@@ -3,6 +3,10 @@
 # only Main files contain this front matter, not partials.
 ---
 
+{% if site.logo %}
+$logo: "{{ site.logo | absolute_url }}";
+{% endif %}
+
 //
 // Import external dependencies
 //
-- 
GitLab