Browse Source

Enable main menu to be left aligned

George Cushen 7 years ago
parent
commit
b6e1dd2710
2 changed files with 12 additions and 2 deletions
  1. 3 0
      exampleSite/config.toml
  2. 9 2
      layouts/partials/navbar.html

+ 3 - 0
exampleSite/config.toml

@@ -227,6 +227,9 @@ defaultContentLanguageInSubdir = false
 #   To link a homepage widget, specify the URL as a hash `#` followed by the filename of the
 #     desired widget in your `content/home/` folder.
 #   The weight parameter defines the order that the links will appear in.
+[params.menus]
+  # Align the main menu to the right of the page? (true/false)
+  align_right = true
 
 [[menu.main]]
   name = "Home"

+ 9 - 2
layouts/partials/navbar.html

@@ -25,7 +25,8 @@
     <div class="collapse navbar-collapse">
 
       <!-- Left Nav Bar -->
-      <ul class="nav navbar-nav navbar-right">
+      {{ $align_right := .Site.Params.menus.align_right | default true }}
+      <ul class="nav navbar-nav {{ if $align_right }}navbar-right{{ else }}navbar-left{{ end }}">
         {{ range .Site.Menus.main }}
 
         {{ if .HasChildren }}
@@ -57,8 +58,14 @@
 
         {{ end }}
         {{ end }}
+      {{ if and .IsTranslated (not $align_right) }}
+      </ul>
+      {{ end }}
 
-        {{ if .IsTranslated }}
+      {{ if .IsTranslated }}
+      {{ if not $align_right }}
+      <ul class="nav navbar-nav navbar-right">
+      {{ end }}
         <li class="dropdown">
           <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true">
             <i class="fa fa-globe" aria-hidden="true"></i>