summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exampleSite/config.toml12
-rw-r--r--exampleSite/config.yaml10
-rw-r--r--exampleSite/content/menu/index.md1
-rw-r--r--exampleSite/content/posts/_index.md6
-rw-r--r--layouts/partials/docs/menu-hugo.html21
-rw-r--r--layouts/partials/docs/menu.html3
-rw-r--r--layouts/partials/docs/title.html4
7 files changed, 56 insertions, 1 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 7fe97ac..65c9f0e 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -36,6 +36,18 @@ enableGitInfo = true
contentDir = 'content.cn'
weight = 3
+[menu]
+# [[menu.before]]
+[[menu.after]]
+ name = "Github"
+ url = "https://github.com/alex-shpak/hugo-book"
+ weight = 10
+
+[[menu.after]]
+ name = "Hugo Themes"
+ url = "https://themes.gohugo.io/hugo-book/"
+ weight = 20
+
[params]
# (Optional, default true) Controls table of contents visibility on right side of pages.
# Start and end levels can be controlled with markup.tableOfContents setting.
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 889f96b..3c9cb45 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -34,6 +34,16 @@ languages:
contentDir: content.cn
weight: 3
+menu:
+ # before: []
+ after:
+ - name: "Github"
+ url: "https://github.com/alex-shpak/hugo-book"
+ weight: 10
+ - name: "Hugo Themes"
+ url: "https://themes.gohugo.io/hugo-book/"
+ weight: 20
+
params:
# (Optional, default true) Controls table of contents visibility on right side of pages.
# Start and end levels can be controlled with markup.tableOfContents setting.
diff --git a/exampleSite/content/menu/index.md b/exampleSite/content/menu/index.md
index d5e9807..4241df7 100644
--- a/exampleSite/content/menu/index.md
+++ b/exampleSite/content/menu/index.md
@@ -1,6 +1,5 @@
---
headless: true
-bookMenuLevels: 1
---
- [**Example Site**]({{< relref "/docs/example" >}})
diff --git a/exampleSite/content/posts/_index.md b/exampleSite/content/posts/_index.md
new file mode 100644
index 0000000..996c430
--- /dev/null
+++ b/exampleSite/content/posts/_index.md
@@ -0,0 +1,6 @@
+---
+menu:
+ after:
+ weight: 5
+title: Blog
+---
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 }}