فهرست منبع

config: Add option to display logo instead of title in nav bar (#214)

* Add `logo = ""` to `[params]` config
George Cushen 7 سال پیش
والد
کامیت
41d0123b54
3فایلهای تغییر یافته به همراه19 افزوده شده و 1 حذف شده
  1. 4 0
      exampleSite/config.toml
  2. 8 0
      layouts/partials/css/academic.css
  3. 7 1
      layouts/partials/navbar.html

+ 4 - 0
exampleSite/config.toml

@@ -57,6 +57,10 @@ defaultContentLanguageInSubdir = false
   # Enable Keybase in Contact section by entering your keybase.io username.
   keybase = ""
 
+  # Diplay a logo in navigation bar rather than title (optional).
+  #   To enable, place an image in `static/img/` and reference its filename below. To disable, set the value to "".
+  logo = ""
+
   # Enable Google Maps by entering your API key, latitude, and longitude.
   #   Get your API key: https://developers.google.com/maps/documentation/javascript/get-api-key
   #   Get your coords: Right-click place on Google Maps. Select 'What's here?'. At the bottom is a card with the coords.

+ 8 - 0
layouts/partials/css/academic.css

@@ -1024,6 +1024,10 @@ nav#navbar-main li {
   padding-bottom: 10px;
 }
 
+.navbar-brand img {
+  max-height: 50px;
+}
+
 .navbar-default .navbar-toggle .icon-bar {
   background-color: {{ .Get "menu_text" }} !important;
 }
@@ -1092,6 +1096,10 @@ nav#navbar-main li {
     padding-bottom: 5px;
   }
 
+  .navbar-brand img {
+    max-height: 40px;
+  }
+
   .navbar-header {
     float: none;
     min-height: inherit;

+ 7 - 1
layouts/partials/navbar.html

@@ -12,7 +12,13 @@
         <span class="icon-bar"></span>
       </button>
       {{ end }}
-      <a class="navbar-brand" href="{{ "/" | relLangURL }}">{{ .Site.Title }}</a>
+      <a class="navbar-brand" href="{{ "/" | relLangURL }}">
+        {{- if .Site.Params.logo -}}
+        <img src="{{ printf "/img/%s" .Site.Params.logo | relURL }}" alt="{{ .Site.Title }}">
+        {{- else -}}
+        {{- .Site.Title -}}
+        {{- end -}}
+      </a>
     </div>
 
     <!-- Collect the nav links, forms, and other content for toggling -->