43 lines
1.1 KiB
HTML
43 lines
1.1 KiB
HTML
<!--
|
|
This is template for hugo menus, accepts Page and Menu as context
|
|
https://gohugo.io/variables/menus/
|
|
-->
|
|
{{- if .Menu -}}
|
|
{{- template "book-menu-hugo" . -}}
|
|
{{- end -}}
|
|
|
|
{{ define "book-menu-hugo" }}
|
|
<ul>
|
|
{{- range .Menu -}}
|
|
{{- $class := slice -}}
|
|
{{- with .Params.class -}}
|
|
{{- $class = $class | append . -}}
|
|
{{- end -}}
|
|
{{- if $.Page.IsMenuCurrent .Menu . -}}
|
|
{{- $class = $class | append "active" -}}
|
|
{{- end -}}
|
|
<li>
|
|
{{- $isRemote := (urls.Parse .URL).IsAbs -}}
|
|
<a href="{{ .URL }}"
|
|
{{- with $class }}class="{{ delimit . " " }}"{{ end -}}
|
|
{{- with .Title }}title="{{ . }}"{{ end -}}
|
|
{{- if $isRemote }}target="_blank" rel="noopener"{{ end -}}>
|
|
{{- .Pre -}}
|
|
{{ template "book-menu-title" . }}
|
|
{{- .Post -}}
|
|
</a>
|
|
{{- with .Children }}
|
|
{{ template "book-menu-hugo" (dict "Page" $.Page "Menu" .) }}
|
|
{{- end }}
|
|
</li>
|
|
{{- end -}}
|
|
</ul>
|
|
{{ end }}
|
|
|
|
{{ define "book-menu-title" }}
|
|
{{ if .Name }}
|
|
{{ .Name }}
|
|
{{ else if .Page }}
|
|
{{ partial "docs/title" .Page }}
|
|
{{ end }}
|
|
{{ end }} |