{{ if $.Site.Params.menu }}
{{ $.Scratch.Set "menuItems" $.Site.Params.menu }}
{{ else }}
{{ $.Scratch.Set "_pages" (slice) }}
{{ range $key, $value := .Site.Sections }}
{{ $sectionPage := $.Site.GetPage "section" $key }}
{{ if $sectionPage.Content }}
{{ $.Scratch.Add "_pages" $sectionPage }}
{{ else if gt $value.Len 0 }}
{{ $.Scratch.Add "_pages" (index $value 0).Page }}
{{ end }}
{{ end }}
{{ $.Scratch.Set "menuItems" (slice)}}
{{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }}
{{ $.Scratch.Add "menuItems" $value.Section }}
{{ end }}
{{ end }}
{{ $menuItems := $.Scratch.Get "menuItems" }}
{{ range $i, $key := $menuItems }}
{{ if ne $key "" }}
{{ $value := (index $.Site.Sections $key) }}
{{ $.Scratch.Set "_value" $value }}
{{ with $index := $.Site.GetPage "section" $key }}
{{ if .Content }}
{{ $.Scratch.Set "first" $index }}
{{ else if gt $value.Len 0}}
{{ $.Scratch.Set "first" (index $value 0).Page }}
{{ if gt $value.Len 1 }}
{{ $.Scratch.Set "_value" (after 1 $value) }}
{{ else }}
{{ $.Scratch.Set "_value" nil }}
{{ end }}
{{ end }}
{{ end }}
{{ $first := $.Scratch.Get "first" }}
{{ $value := $.Scratch.Get "_value" }}
-
{{ if isset $first.Params "icon" }}
{{ printf $first.Params.icon | safeHTML }}
{{ end }}
{{ $first.Title }}
{{ if $.Site.Params.showVisitedLinks}}
{{ end }}
{{ if gt $value.Len 0}}
{{ end }}
{{ end }}
{{ end }}
{{ if .Site.Params.showVisitedLinks}}
Clear History
{{ end }}