| | |
| | | {{- /* |
| | | Site header navigation. |
| | | |
| | | Every element has a stable `ananke-nav-*` or `ananke-submenu*` hook class |
| | | for custom CSS. The Tachyons classes next to it are defaults; replace them |
| | | per element with `[params.ananke.navigation.classes]`. Collapsing (below the |
| | | Tachyons `-l` breakpoint) and the dropdown position are in _styles.css. |
| | | |
| | | Hooks: `navigation-start` renders after the brand link (for example a search |
| | | box), `navigation-end` renders at the end of the collapsible panel. |
| | | |
| | | Without JavaScript, the menu and all submenus are visible and the toggle |
| | | buttons stay hidden. site-scripts.html enhances both. |
| | | */ -}} |
| | | |
| | | {{- /* Returns the classes for each navigation element: configured or default. */ -}} |
| | | {{- define "_partials/AnankeNavigationClasses.html" -}} |
| | | {{- $rtl := compare.Eq site.Language.Direction "rtl" -}} |
| | | {{- $background := site.Params.background_color_class | compare.Default "bg-black" -}} |
| | | {{- $defaults := collections.Dictionary |
| | | "nav" "pv3 ph3 ph4-ns" |
| | | "inner" "flex flex-wrap items-center justify-between center" |
| | | "brand" "f3 fw2 hover-white white-90 dib no-underline" |
| | | "toggle" "f5 white-90 hover-white" |
| | | "panel" "flex-l items-center" |
| | | "menu" (compare.Conditional $rtl "pr0 ml3" "pl0 mr3") |
| | | "item" (printf "list f5 f4-ns fw4 dib %s" (compare.Conditional $rtl "pl3" "pr3")) |
| | | "link" "hover-white white-90 no-underline" |
| | | "submenu_toggle" "hover-white white-90" |
| | | "submenu" (printf "list ma0 pv2 ph0 br2 ba b--white-20 %s" $background) |
| | | "submenu_link" "db pv2 ph3 f5 white-90 hover-white hover-bg-white-10 no-underline" |
| | | -}} |
| | | {{- $configured := collections.Dictionary -}} |
| | | {{- with site.Params.ananke.navigation -}} |
| | | {{- with .classes -}}{{- $configured = . -}}{{- end -}} |
| | | {{- end -}} |
| | | {{- $classes := collections.Dictionary -}} |
| | | {{- range $key, $default := $defaults -}} |
| | | {{- $value := collections.Index $configured $key | compare.Default $default -}} |
| | | {{- $classes = collections.Merge $classes (collections.Dictionary $key $value) -}} |
| | | {{- end -}} |
| | | {{- return $classes -}} |
| | | {{- end -}} |
| | | |
| | | {{- /* |
| | | Returns the aria-current value for a menu entry: "page" if it links to the |
| | | current page, "true" if the current page is below it (Hugo's HasMenuCurrent, |
| | | which includes pages inside the entry's section), or an empty string. |
| | |
| | | {{- end -}} |
| | | |
| | | {{- define "_partials/AnankeSubmenuIcon.html" -}} |
| | | <svg class="ananke-submenu-icon" aria-hidden="true" focusable="false" width="12" height="12" viewBox="0 0 12 12"><path d="M2 4.5l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/></svg> |
| | | <svg class="ananke-submenu-icon" aria-hidden="true" focusable="false" width="12" height="12" viewBox="0 0 12 12"><path d="M2 4.5l4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg> |
| | | {{- end -}} |
| | | |
| | | {{- define "_partials/AnankeMenuToggleIcon.html" -}} |
| | | <svg class="ananke-nav-toggle-icon" aria-hidden="true" focusable="false" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"><path class="ananke-nav-toggle-line" d="M3 5h14"/><path class="ananke-nav-toggle-line" d="M3 10h14"/><path class="ananke-nav-toggle-line" d="M3 15h14"/></svg> |
| | | {{- end -}} |
| | | |
| | | {{- define "_partials/AnankeSubmenu.html" -}} |
| | | {{- $page := .page }} |
| | | <ul {{ with .id }}id="{{ . }}" class="ananke-submenu list pa0 ma0 {{ $page.Site.Params.background_color_class | compare.Default "bg-black" }}"{{ else }}class="ananke-submenu-nested list ma0"{{ end }}> |
| | | {{- $classes := .classes }} |
| | | <ul {{ with .id }}id="{{ . }}" class="ananke-submenu {{ $classes.submenu }}"{{ else }}class="ananke-submenu-nested list ma0 pa0"{{ end }}> |
| | | {{- range .entries }} |
| | | {{- $current := partials.Include "AnankeMenuCurrent.html" (dict "page" $page "entry" .) }} |
| | | <li class="ananke-submenu-item"> |
| | | {{- if .URL }} |
| | | <a class="hover-white white-90 no-underline" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}>{{ .Name }}</a> |
| | | <a class="ananke-submenu-link {{ $classes.submenu_link }}" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}>{{ .Name }}</a> |
| | | {{- else }} |
| | | <span class="white-90">{{ .Name }}</span> |
| | | <span class="ananke-submenu-link {{ $classes.submenu_link }}">{{ .Name }}</span> |
| | | {{- end }} |
| | | {{- with .Children }} |
| | | {{ partials.Include "AnankeSubmenu.html" (dict "page" $page "entries" .) }} |
| | | {{ partials.Include "AnankeSubmenu.html" (dict "page" $page "entries" . "classes" $classes) }} |
| | | {{- end }} |
| | | </li> |
| | | {{- end }} |
| | | </ul> |
| | | {{- end -}} |
| | | <nav class="pv3 ph3 ph4-ns" role="navigation"> |
| | | <div class="flex-l center items-center justify-between"> |
| | | <a href="{{ .Site.Home.RelPermalink }}" class="f3 fw2 hover-white white-90 dib no-underline"> |
| | | {{- $classes := partials.Include "AnankeNavigationClasses.html" . -}} |
| | | <nav class="ananke-nav {{ $classes.nav }}" role="navigation"> |
| | | <div class="ananke-nav-inner {{ $classes.inner }}"> |
| | | <a href="{{ .Site.Home.RelPermalink }}" class="ananke-nav-brand {{ $classes.brand }}"> |
| | | {{ with .Site.Params.site_logo }} |
| | | <img src="{{ urls.RelURL . }}" class="w100 mw5-ns" alt="{{ $.Site.Title }}" /> |
| | | {{ else }} |
| | | {{ .Site.Title }} |
| | | {{ end }} |
| | | </a> |
| | | <div class="flex-l items-center"> |
| | | {{- with partials.Include "hook.html" (dict "hook" "navigation-start" "context" .) | strings.TrimSpace }} |
| | | <div class="ananke-nav-slot">{{ . | safeHTML }}</div> |
| | | {{- end }} |
| | | {{- if .Site.Menus.main }} |
| | | <button type="button" class="ananke-nav-toggle {{ $classes.toggle }}" aria-expanded="false" aria-controls="ananke-nav-panel" hidden> |
| | | {{- partials.Include "AnankeMenuToggleIcon.html" -}} |
| | | <span class="ananke-nav-toggle-label">{{ lang.Translate "menuToggle" }}</span> |
| | | </button> |
| | | {{- end }} |
| | | <div id="ananke-nav-panel" class="ananke-nav-panel {{ $classes.panel }}"> |
| | | {{ partials.Include "i18nlist.html" . }} |
| | | {{ if .Site.Menus.main }} |
| | | <ul class="{{ compare.Conditional (compare.Eq $.Site.Language.Direction "rtl") "pr0 ml3" "pl0 mr3" }}"> |
| | | <ul class="ananke-nav-menu {{ $classes.menu }}"> |
| | | {{ range $index, $entry := .Site.Menus.main }} |
| | | {{- $current := partials.Include "AnankeMenuCurrent.html" (dict "page" $ "entry" $entry) -}} |
| | | {{- if not $entry.HasChildren }} |
| | | <li class="list f5 f4-ns fw4 dib {{ compare.Conditional (compare.Eq $.Site.Language.Direction "rtl") "pl3" "pr3" }}"> |
| | | <a class="hover-white white-90 no-underline" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}> |
| | | <li class="ananke-nav-item {{ $classes.item }}"> |
| | | <a class="ananke-nav-link {{ $classes.link }}" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}> |
| | | {{ .Name }} |
| | | </a> |
| | | </li> |
| | | {{- else }} |
| | | {{- /* |
| | | A parent entry with children. The child list is always in the |
| | | markup, so it stays reachable without JavaScript. The toggle button |
| | | is hidden until site-scripts.html reveals it and collapses the list. |
| | | Entries below the second level render as nested lists inside the |
| | | submenu, without their own toggle. |
| | | markup, so it stays reachable without JavaScript. Entries below the |
| | | second level render as nested lists inside the submenu, without |
| | | their own toggle. |
| | | */}} |
| | | {{- $submenu_id := printf "ananke-submenu-%d" $index }} |
| | | <li class="list f5 f4-ns fw4 dib {{ compare.Conditional (compare.Eq $.Site.Language.Direction "rtl") "pl3" "pr3" }} ananke-has-submenu"> |
| | | <li class="ananke-nav-item ananke-has-submenu {{ $classes.item }}"> |
| | | {{- if .URL }} |
| | | <a class="hover-white white-90 no-underline" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}> |
| | | <a class="ananke-nav-link {{ $classes.link }}" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}> |
| | | {{ .Name }} |
| | | </a> |
| | | <button type="button" class="ananke-submenu-toggle hover-white white-90" aria-expanded="false" aria-controls="{{ $submenu_id }}" hidden> |
| | | <button type="button" class="ananke-submenu-toggle {{ $classes.submenu_toggle }}" aria-expanded="false" aria-controls="{{ $submenu_id }}" hidden> |
| | | <span class="clip">{{ lang.Translate "submenuToggle" . | compare.Default .Name }}</span> |
| | | {{- partials.Include "AnankeSubmenuIcon.html" }} |
| | | </button> |
| | | {{- else }} |
| | | <span class="white-90 ananke-submenu-label">{{ .Name }}</span> |
| | | <button type="button" class="ananke-submenu-toggle hover-white white-90" aria-expanded="false" aria-controls="{{ $submenu_id }}"{{ with $current }} aria-current="{{ . }}"{{ end }} hidden> |
| | | <span class="ananke-submenu-label {{ $classes.link }}">{{ .Name }}</span> |
| | | <button type="button" class="ananke-submenu-toggle {{ $classes.submenu_toggle }}" aria-expanded="false" aria-controls="{{ $submenu_id }}"{{ with $current }} aria-current="{{ . }}"{{ end }} hidden> |
| | | {{ .Name }} |
| | | {{- partials.Include "AnankeSubmenuIcon.html" }} |
| | | </button> |
| | | {{- end }} |
| | | {{ partials.Include "AnankeSubmenu.html" (dict "page" $ "entries" .Children "id" $submenu_id) }} |
| | | {{ partials.Include "AnankeSubmenu.html" (dict "page" $ "entries" .Children "id" $submenu_id "classes" $classes) }} |
| | | </li> |
| | | {{- end }} |
| | | {{ end }} |
| | | </ul> |
| | | {{ end }} |
| | | {{ partials.IncludeCached "social/follow.html" . }} |
| | | {{- with partials.Include "hook.html" (dict "hook" "navigation-end" "context" .) | strings.TrimSpace }} |
| | | <div class="ananke-nav-end">{{ . | safeHTML }}</div> |
| | | {{- end }} |
| | | </div> |
| | | </div> |
| | | </nav> |