mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-22 11:29:28 +00:00
Add support for hugo menus
This commit is contained in:
parent
59479b17ac
commit
2088c9a0cb
@ -36,6 +36,18 @@ enableGitInfo = true
|
|||||||
contentDir = 'content.cn'
|
contentDir = 'content.cn'
|
||||||
weight = 3
|
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]
|
[params]
|
||||||
# (Optional, default true) Controls table of contents visibility on right side of pages.
|
# (Optional, default true) Controls table of contents visibility on right side of pages.
|
||||||
# Start and end levels can be controlled with markup.tableOfContents setting.
|
# Start and end levels can be controlled with markup.tableOfContents setting.
|
||||||
|
@ -34,6 +34,16 @@ languages:
|
|||||||
contentDir: content.cn
|
contentDir: content.cn
|
||||||
weight: 3
|
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:
|
params:
|
||||||
# (Optional, default true) Controls table of contents visibility on right side of pages.
|
# (Optional, default true) Controls table of contents visibility on right side of pages.
|
||||||
# Start and end levels can be controlled with markup.tableOfContents setting.
|
# Start and end levels can be controlled with markup.tableOfContents setting.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
headless: true
|
headless: true
|
||||||
bookMenuLevels: 1
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- [**Example Site**]({{< relref "/docs/example" >}})
|
- [**Example Site**]({{< relref "/docs/example" >}})
|
||||||
|
6
exampleSite/content/posts/_index.md
Normal file
6
exampleSite/content/posts/_index.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
menu:
|
||||||
|
after:
|
||||||
|
weight: 5
|
||||||
|
title: Blog
|
||||||
|
---
|
21
layouts/partials/docs/menu-hugo.html
Normal file
21
layouts/partials/docs/menu-hugo.html
Normal file
@ -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 }}
|
@ -1,7 +1,9 @@
|
|||||||
<nav>
|
<nav>
|
||||||
{{ partial "docs/brand" . }}
|
{{ partial "docs/brand" . }}
|
||||||
{{ partial "docs/search" . }}
|
{{ partial "docs/search" . }}
|
||||||
|
|
||||||
{{ partial "docs/inject/menu-before" . }}
|
{{ partial "docs/inject/menu-before" . }}
|
||||||
|
{{ partial "docs/menu-hugo" .Site.Menus.before }}
|
||||||
|
|
||||||
{{ if .Site.Params.BookMenuBundle }}
|
{{ if .Site.Params.BookMenuBundle }}
|
||||||
{{ partial "docs/menu-bundle" . }}
|
{{ partial "docs/menu-bundle" . }}
|
||||||
@ -9,6 +11,7 @@
|
|||||||
{{ partial "docs/menu-filetree" . }}
|
{{ partial "docs/menu-filetree" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ partial "docs/menu-hugo" .Site.Menus.after }}
|
||||||
{{ partial "docs/inject/menu-after" . }}
|
{{ partial "docs/inject/menu-after" . }}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
Partial to generate page name from Title or File name.
|
||||||
|
Accepts Page as context
|
||||||
|
-->
|
||||||
{{ $title := "" }}
|
{{ $title := "" }}
|
||||||
|
|
||||||
{{ if .Title }}
|
{{ if .Title }}
|
||||||
|
Loading…
Reference in New Issue
Block a user