From 2088c9a0cb5e41554ad450a464b54f4c628e712b Mon Sep 17 00:00:00 2001
From: Alex Shpak <alex-shpak@users.noreply.github.com>
Date: Wed, 12 Feb 2020 22:12:41 +0100
Subject: Add support for hugo menus

---
 layouts/partials/docs/menu-hugo.html | 21 +++++++++++++++++++++
 layouts/partials/docs/menu.html      |  3 +++
 layouts/partials/docs/title.html     |  4 ++++
 3 files changed, 28 insertions(+)
 create mode 100644 layouts/partials/docs/menu-hugo.html

(limited to 'layouts/partials/docs')

diff --git a/layouts/partials/docs/menu-hugo.html b/layouts/partials/docs/menu-hugo.html
new file mode 100644
index 0000000..e21e8cb
--- /dev/null
+++ b/layouts/partials/docs/menu-hugo.html
@@ -0,0 +1,21 @@
+<!--
+  This is template for hugo menus, accepts MenuEntity as context
+  https://gohugo.io/variables/menus/
+-->
+{{ if . }}
+<ul>
+  {{ range . }}
+  <li>
+    <a href="{{ .URL }}" {{ if not .Page }}target="_blank" rel="noopener"{{ end }}>
+      {{- .Pre -}}
+      {{ with .Page }}
+        {{ partial "docs/title" .Page }}
+      {{ else }}
+        {{ .Name }}
+      {{ end }}
+      {{- .Post -}}
+    </a>
+  </li>
+  {{ end }}
+</ul>
+{{ end }}
diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html
index a0d3c45..3a71f42 100644
--- a/layouts/partials/docs/menu.html
+++ b/layouts/partials/docs/menu.html
@@ -1,7 +1,9 @@
 <nav>
 {{ partial "docs/brand" . }}
 {{ partial "docs/search" . }}
+
 {{ partial "docs/inject/menu-before" . }}
+{{ partial "docs/menu-hugo" .Site.Menus.before }}
 
 {{ if .Site.Params.BookMenuBundle }}
   {{ partial "docs/menu-bundle" . }}
@@ -9,6 +11,7 @@
   {{ partial "docs/menu-filetree" . }}
 {{ end }}
 
+{{ partial "docs/menu-hugo" .Site.Menus.after }}
 {{ partial "docs/inject/menu-after" . }}
 </nav>
 
diff --git a/layouts/partials/docs/title.html b/layouts/partials/docs/title.html
index f32e8da..ffe858a 100644
--- a/layouts/partials/docs/title.html
+++ b/layouts/partials/docs/title.html
@@ -1,3 +1,7 @@
+<!-- 
+  Partial to generate page name from Title or File name.
+  Accepts Page as context
+-->
 {{ $title := "" }}
 
 {{ if .Title }}
-- 
cgit v1.2.3