Add default menu
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
{{ $first := templates.Exists "partials/paige/site-header-first.html" }}
|
||||
{{ $last := templates.Exists "partials/paige/site-header-last.html" }}
|
||||
{{ $links := false }}
|
||||
{{ $menu := site.Menus.main | and ($page.Param "paige.site.disable_menu" | not) }}
|
||||
{{ $menu := $page.Param "paige.site.disable_menu" | not }}
|
||||
{{ $pills := false }}
|
||||
{{ $tabs := false }}
|
||||
{{ $title := $page.Param "paige.title" | default site.Title | markdownify | and ($page.Param "paige.site.disable_title" | not) }}
|
||||
@@ -46,44 +46,72 @@
|
||||
<div class="lead paige-row-wide text-center" id="paige-site-description">{{ . }}</div>
|
||||
{{ end }}
|
||||
|
||||
{{ with $menu }}
|
||||
<nav aria-label="{{ i18n `paige_menu` }}" class="paige-row-wide" id="paige-menu">
|
||||
<ul class="align-items-center justify-content-center nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ else if $underline }} nav-underline {{ end }}">
|
||||
{{ range . }}
|
||||
{{ $menupath := strings.TrimPrefix $basepath .URL }}
|
||||
{{ $home := and (eq $menupath "/") (eq $pagepath "/") }}
|
||||
{{ $menuprefix := and (ne $menupath "/") (hasPrefix $pagepath $menupath) }}
|
||||
{{ $sectionprefix := and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section)) }}
|
||||
{{ $active := or $home $menuprefix $sectionprefix }}
|
||||
{{ if $menu }}
|
||||
{{ with site.Menus.main }}
|
||||
<nav aria-label="{{ i18n `paige_menu` }}" class="paige-row-wide" id="paige-menu">
|
||||
<ul class="align-items-center justify-content-center nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ else if $underline }} nav-underline {{ end }}">
|
||||
{{ range . }}
|
||||
{{ $menupath := strings.TrimPrefix $basepath .URL }}
|
||||
{{ $home := and (eq $menupath "/") (eq $pagepath "/") }}
|
||||
{{ $menuprefix := and (ne $menupath "/") (hasPrefix $pagepath $menupath) }}
|
||||
{{ $sectionprefix := and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section)) }}
|
||||
{{ $active := or $home $menuprefix $sectionprefix }}
|
||||
|
||||
<li class="nav-item {{ if .Children }} dropdown {{ end }}">
|
||||
<a {{ if $active }} aria-current="page" {{ end }} {{ if .Children }} aria-expanded="false" {{ end }} class="{{ if $active }} active {{ if $links }} fw-bold text-body-emphasis {{ end }} {{ end }} {{ if .Params.paige.disabled }} disabled {{ end }} nav-link {{ if .Children }} dropdown-toggle {{ end }} {{ if $links }} text-decoration-underline {{ end }}" {{ if .Children }} data-bs-toggle="dropdown" {{ end }} href="{{ if .Children -}} # {{- else -}} {{ .URL | safeURL }} {{- end }}" {{ if .Children }} role="button" {{ end }} {{ if not .Children }} {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }} {{ end }}>{{ .Name }}</a>
|
||||
<li class="nav-item {{ if .Children }} dropdown {{ end }}">
|
||||
<a {{ if $active }} aria-current="page" {{ end }} {{ if .Children }} aria-expanded="false" {{ end }} class="{{ if $active }} active {{ if $links }} fw-bold text-body-emphasis {{ end }} {{ end }} {{ if .Params.paige.disabled }} disabled {{ end }} nav-link {{ if .Children }} dropdown-toggle {{ end }} {{ if $links }} text-decoration-underline {{ end }}" {{ if .Children }} data-bs-toggle="dropdown" {{ end }} href="{{ if .Children -}} # {{- else -}} {{ .URL | safeURL }} {{- end }}" {{ if .Children }} role="button" {{ end }} {{ if not .Children }} {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }} {{ end }}>{{ .Name }}</a>
|
||||
|
||||
{{ with .Children }}
|
||||
<ul class="dropdown-menu">
|
||||
{{ range . }}
|
||||
{{ if .Params.paige.divider_above }}
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Children }}
|
||||
<ul class="dropdown-menu">
|
||||
{{ range . }}
|
||||
{{ if .Params.paige.divider_above }}
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
<a class="{{ if .Params.paige.disabled }} disabled {{ end }} dropdown-item" href="{{ .URL | safeURL }}" {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }}>{{ .Name }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
|
||||
<li>
|
||||
<a class="{{ if .Params.paige.disabled }} disabled {{ end }} dropdown-item" href="{{ .URL | safeURL }}" {{ with partial "paige/target.html" (dict "page" $page "url" .URL) }} target="{{ . }}" {{ end }}>{{ .Name }}</a>
|
||||
</li>
|
||||
|
||||
{{ if .Params.paige.divider_below }}
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
{{ if .Params.paige.divider_below }}
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</nav>
|
||||
{{ else }}
|
||||
{{ $ordered := slice site.Home | append site.Sections }}
|
||||
|
||||
{{ range $name, $taxonomy := site.Taxonomies }}
|
||||
{{ if and $taxonomy.Page $taxonomy.Page.RelPermalink }}
|
||||
{{ $ordered = $ordered | append $taxonomy.Page }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
||||
{{ $ordered = sort $ordered "Title" }}
|
||||
|
||||
<nav aria-label="{{ i18n `paige_menu` }}" class="paige-row-wide" id="paige-menu">
|
||||
<ul class="align-items-center justify-content-center nav {{ if $pills }} nav-pills {{ else if $tabs }} nav-tabs {{ else if $underline }} nav-underline {{ end }}">
|
||||
{{ range $ordered }}
|
||||
{{ $menupath := strings.TrimPrefix $basepath .RelPermalink }}
|
||||
{{ $home := and (eq $menupath "/") (eq $pagepath "/") }}
|
||||
{{ $menuprefix := and (ne $menupath "/") (hasPrefix $pagepath $menupath) }}
|
||||
{{ $sectionprefix := and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section)) }}
|
||||
{{ $active := or $home $menuprefix $sectionprefix }}
|
||||
|
||||
<li class="nav-item">
|
||||
<a {{ if $active }} aria-current="page" {{ end }} class="{{ if $active }} active {{ if $links }} fw-bold text-body-emphasis {{ end }} {{ end }} nav-link {{ if $links }} text-decoration-underline {{ end }}" href="{{ .RelPermalink | safeURL }}" {{ with partial "paige/target.html" (dict "page" $page "url" .RelPermalink) }} target="{{ . }}" {{ end }}>{{ .Title }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ with $breadcrumbs }}
|
||||
|
Reference in New Issue
Block a user