Files
libertytoolsio/themes/hugo-book.backup/layouts/_partials/docs/menu-hugo.html

46 lines
1.2 KiB
HTML
Raw Normal View History

<!--
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" }}
{{- with .Params.BookIcon -}}
<img src="{{ partial "docs/icon" . }}" class="book-icon" alt="{{ partial "docs/text/i18n" . }}" />
{{- end -}}
{{- if .Name -}}
{{- .Name -}}
{{- else if .Page -}}
{{- partial "docs/title" .Page -}}
{{- end -}}
{{ end }}