From 8263c013685ba4e5628315ff8c3125ebf286fd7e Mon Sep 17 00:00:00 2001
From: Patrick Kollitsch <davidsneighbourdev+gh@gmail.com>
Date: Thu, 19 Nov 2026 11:51:55 +0000
Subject: [PATCH] refactor(layouts): render header parts through hooks
---
layouts/_partials/func/header/GetNavigationClasses.html | 31 ++++
layouts/_partials/header/menu-toggle-icon.html | 2
layouts/_partials/site-header.html | 19 --
layouts/_partials/page-header.html | 7
layouts/_partials/header/component.html | 30 ++++
layouts/_partials/hooks/header/languages.html | 5
layouts/_partials/hooks/header/logo.html | 12 +
layouts/_partials/header/submenu-icon.html | 2
layouts/_partials/site-navigation.html | 138 ++-----------------
layouts/_partials/header/content.html | 12 +
layouts/_partials/func/header/GetMenuCurrent.html | 15 ++
layouts/_partials/hooks/header/social.html | 5
layouts/_partials/hooks/header/title.html | 15 ++
layouts/_partials/hooks/header/menu.html | 49 +++++++
layouts/_partials/header/submenu.html | 27 +++
layouts/_partials/hooks/header/description.html | 23 +++
16 files changed, 247 insertions(+), 145 deletions(-)
diff --git a/layouts/_partials/func/header/GetMenuCurrent.html b/layouts/_partials/func/header/GetMenuCurrent.html
new file mode 100644
index 0000000..659bbe6
--- /dev/null
+++ b/layouts/_partials/func/header/GetMenuCurrent.html
@@ -0,0 +1,15 @@
+{{- /*
+ 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.
+
+ @param page page The current page.
+ @param entry menu entry The menu entry.
+*/ -}}
+{{- $current := "" -}}
+{{- if .page.IsMenuCurrent "main" .entry -}}
+ {{- $current = "page" -}}
+{{- else if .page.HasMenuCurrent "main" .entry -}}
+ {{- $current = "true" -}}
+{{- end -}}
+{{- return $current -}}
diff --git a/layouts/_partials/func/header/GetNavigationClasses.html b/layouts/_partials/func/header/GetNavigationClasses.html
new file mode 100644
index 0000000..ffc778d
--- /dev/null
+++ b/layouts/_partials/func/header/GetNavigationClasses.html
@@ -0,0 +1,31 @@
+{{- /*
+ Returns the classes for each navigation element: the value from
+ `[params.ananke.navigation.classes]`, or the theme default.
+
+ @return map Element name -> class string.
+*/ -}}
+{{- $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 -}}
diff --git a/layouts/_partials/header/component.html b/layouts/_partials/header/component.html
new file mode 100644
index 0000000..712eb53
--- /dev/null
+++ b/layouts/_partials/header/component.html
@@ -0,0 +1,30 @@
+{{- /*
+ Renders one header component through the hook system.
+
+ For a component named `<name>`, this fires three hooks in order:
+
+ - `header/<name>-before` (empty by default; add your own markup)
+ - `header/<name>` (the component itself; the theme ships defaults
+ for logo, languages, menu, social, title, and
+ description)
+ - `header/<name>-after` (empty by default; add your own markup)
+
+ Each hook partial lives in `layouts/_partials/hooks/header/` and receives the
+ header context dictionary:
+
+ - `page` the current page
+ - `region` "navigation" or "content"
+ - `featured_image` the featured image URL of the page, or an empty string
+ - `variant` "site" or "page" (content region only)
+ - `classes` navigation classes from
+ func/header/GetNavigationClasses.html (navigation
+ region only)
+
+ @param name string Component name.
+ @param context map Header context dictionary (see above).
+*/ -}}
+{{- $name := .name -}}
+{{- $context := .context -}}
+{{- partials.Include "hook.html" (collections.Dictionary "hook" (fmt.Printf "header/%s-before" $name) "context" $context) -}}
+{{- partials.Include "hook.html" (collections.Dictionary "hook" (fmt.Printf "header/%s" $name) "context" $context) -}}
+{{- partials.Include "hook.html" (collections.Dictionary "hook" (fmt.Printf "header/%s-after" $name) "context" $context) -}}
diff --git a/layouts/_partials/header/content.html b/layouts/_partials/header/content.html
new file mode 100644
index 0000000..c1cb3b2
--- /dev/null
+++ b/layouts/_partials/header/content.html
@@ -0,0 +1,12 @@
+{{- /*
+ Header content below the navigation bar: the title and the description of
+ the page. Every part is rendered through the header hooks (see
+ `header/component.html`).
+
+ @param page page The current page.
+ @param variant string "site" (list pages) or "page" (single pages).
+ @param featured_image string Featured image URL, or an empty string.
+*/ -}}
+{{- $header := collections.Merge . (collections.Dictionary "region" "content") -}}
+{{ partials.Include "header/component.html" (collections.Dictionary "name" "title" "context" $header) }}
+{{ partials.Include "header/component.html" (collections.Dictionary "name" "description" "context" $header) }}
diff --git a/layouts/_partials/header/menu-toggle-icon.html b/layouts/_partials/header/menu-toggle-icon.html
new file mode 100644
index 0000000..4927fc7
--- /dev/null
+++ b/layouts/_partials/header/menu-toggle-icon.html
@@ -0,0 +1,2 @@
+{{- /* Icon of the menu button (three lines that turn into a cross). */ -}}
+<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>
\ No newline at end of file
diff --git a/layouts/_partials/header/submenu-icon.html b/layouts/_partials/header/submenu-icon.html
new file mode 100644
index 0000000..7d84783
--- /dev/null
+++ b/layouts/_partials/header/submenu-icon.html
@@ -0,0 +1,2 @@
+{{- /* Chevron icon of a submenu toggle button. */ -}}
+<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>
\ No newline at end of file
diff --git a/layouts/_partials/header/submenu.html b/layouts/_partials/header/submenu.html
new file mode 100644
index 0000000..74dc27a
--- /dev/null
+++ b/layouts/_partials/header/submenu.html
@@ -0,0 +1,27 @@
+{{- /*
+ Renders the child entries of a main menu entry. The top level gets the
+ `ananke-submenu` class and an id for its toggle button; deeper levels render
+ as nested lists without their own toggle.
+
+ @param page page The current page.
+ @param entries menu The child entries.
+ @param classes map Classes from func/header/GetNavigationClasses.html.
+ @param id string Optional. Id of the top-level list.
+*/ -}}
+{{- $page := .page }}
+{{- $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 "func/header/GetMenuCurrent.html" (dict "page" $page "entry" .) }}
+ <li class="ananke-submenu-item">
+ {{- if .URL }}
+ <a class="ananke-submenu-link {{ $classes.submenu_link }}" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}>{{ .Name }}</a>
+ {{- else }}
+ <span class="ananke-submenu-link {{ $classes.submenu_link }}">{{ .Name }}</span>
+ {{- end }}
+ {{- with .Children }}
+ {{ partials.Include "header/submenu.html" (dict "page" $page "entries" . "classes" $classes) }}
+ {{- end }}
+ </li>
+ {{- end }}
+</ul>
diff --git a/layouts/_partials/hooks/header/description.html b/layouts/_partials/hooks/header/description.html
new file mode 100644
index 0000000..04da04a
--- /dev/null
+++ b/layouts/_partials/hooks/header/description.html
@@ -0,0 +1,23 @@
+{{- /*
+ Header component: the `description` from the front matter of the page.
+ Renders nothing if the page has no description.
+
+ The `site` variant (list pages) renders an `h2`. The `page` variant (single
+ pages) renders a `div`.
+*/ -}}
+{{- $context := . -}}
+{{- with .page.Params.description -}}
+ {{- if compare.Eq $context.variant "page" -}}
+ <div class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
+ {{ . }}
+ </div>
+ {{- else if $context.featured_image -}}
+ <h2 class="fw1 f5 f3-l white-80 measure-wide-l center mt3">
+ {{ . }}
+ </h2>
+ {{- else -}}
+ <h2 class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
+ {{ . }}
+ </h2>
+ {{- end -}}
+{{- end -}}
diff --git a/layouts/_partials/hooks/header/languages.html b/layouts/_partials/hooks/header/languages.html
new file mode 100644
index 0000000..9bc8825
--- /dev/null
+++ b/layouts/_partials/hooks/header/languages.html
@@ -0,0 +1,5 @@
+{{- /*
+ Header component: links to the translations of the current page.
+ Renders nothing if the page has no translations.
+*/ -}}
+{{- partials.Include "i18nlist.html" .page -}}
diff --git a/layouts/_partials/hooks/header/logo.html b/layouts/_partials/hooks/header/logo.html
new file mode 100644
index 0000000..e5f73fc
--- /dev/null
+++ b/layouts/_partials/hooks/header/logo.html
@@ -0,0 +1,12 @@
+{{- /*
+ Header component: site logo or site title, linked to the home page.
+ Uses `site_logo` from the site parameters if it is set.
+*/ -}}
+{{- $site := .page.Site -}}
+<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>
diff --git a/layouts/_partials/hooks/header/menu.html b/layouts/_partials/hooks/header/menu.html
new file mode 100644
index 0000000..7fd3d0d
--- /dev/null
+++ b/layouts/_partials/hooks/header/menu.html
@@ -0,0 +1,49 @@
+{{- /*
+ Header component: the `main` menu of the site, with submenus for entries
+ that have children. Renders nothing if the site has no `main` menu.
+
+ The child lists are always in the markup, so they stay reachable without
+ JavaScript. site-scripts.html adds the submenu toggle behaviour.
+*/ -}}
+{{- $page := .page -}}
+{{- $classes := .classes -}}
+{{- if $page.Site.Menus.main -}}
+<ul class="ananke-nav-menu {{ $classes.menu }}">
+ {{ range $index, $entry := $page.Site.Menus.main }}
+ {{- $current := partials.Include "func/header/GetMenuCurrent.html" (dict "page" $page "entry" $entry) -}}
+ {{- if not $entry.HasChildren }}
+ <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. 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="ananke-nav-item ananke-has-submenu {{ $classes.item }}">
+ {{- if .URL }}
+ <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 {{ $classes.submenu_toggle }}" aria-expanded="false" aria-controls="{{ $submenu_id }}" hidden>
+ <span class="clip">{{ lang.Translate "submenuToggle" . | compare.Default .Name }}</span>
+ {{- partials.Include "header/submenu-icon.html" }}
+ </button>
+ {{- else }}
+ <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 "header/submenu-icon.html" }}
+ </button>
+ {{- end }}
+ {{ partials.Include "header/submenu.html" (dict "page" $page "entries" .Children "id" $submenu_id "classes" $classes) }}
+ </li>
+ {{- end }}
+ {{ end }}
+</ul>
+{{- end -}}
diff --git a/layouts/_partials/hooks/header/social.html b/layouts/_partials/hooks/header/social.html
new file mode 100644
index 0000000..38ba67e
--- /dev/null
+++ b/layouts/_partials/hooks/header/social.html
@@ -0,0 +1,5 @@
+{{- /*
+ Header component: "follow" links to the social media profiles that are
+ configured in `params.ananke.social.follow.networks`.
+*/ -}}
+{{- partials.IncludeCached "social/follow.html" .page -}}
diff --git a/layouts/_partials/hooks/header/title.html b/layouts/_partials/hooks/header/title.html
new file mode 100644
index 0000000..e6d4e87
--- /dev/null
+++ b/layouts/_partials/hooks/header/title.html
@@ -0,0 +1,15 @@
+{{- /*
+ Header component: the page title, or the site title if the page has none.
+
+ The `site` variant (list pages) renders an `h1`. The `page` variant (single
+ pages) renders a `div`, because the article itself contains the `h1`.
+*/ -}}
+{{- $page := .page -}}
+{{- $title := $page.Title | compare.Default $page.Site.Title -}}
+{{- if compare.Eq .variant "page" -}}
+ <div class="f2 f1-l fw2 white-90 mb0 lh-title">{{ $title }}</div>
+{{- else -}}
+ <h1 class="f2 f-subheadline-l fw2 {{ compare.Conditional (compare.Ne .featured_image "") "white-90" "light-silver" }} mb0 lh-title">
+ {{ $title }}
+ </h1>
+{{- end -}}
diff --git a/layouts/_partials/page-header.html b/layouts/_partials/page-header.html
index 393988c..82f2f96 100644
--- a/layouts/_partials/page-header.html
+++ b/layouts/_partials/page-header.html
@@ -34,12 +34,7 @@
{{ partials.Include "site-navigation.html" . }}
<div class="{{ $header_section_class }}">
{{ if not .Params.omit_header_text }}
- <div class="f2 f1-l fw2 white-90 mb0 lh-title">{{ .Title | compare.Default .Site.Title }}</div>
- {{ with .Params.description }}
- <div class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
- {{ . }}
- </div>
- {{ end }}
+ {{ partials.Include "header/content.html" (collections.Dictionary "page" . "variant" "page" "featured_image" $featured_image) }}
{{ end }}
</div>
</div>
diff --git a/layouts/_partials/site-header.html b/layouts/_partials/site-header.html
index 19ba931..e8d9c17 100644
--- a/layouts/_partials/site-header.html
+++ b/layouts/_partials/site-header.html
@@ -1,4 +1,5 @@
{{ $featured_image := partials.Include "func/GetFeaturedImage.html" . }}
+{{ $header := collections.Dictionary "page" . "variant" "site" "featured_image" $featured_image }}
{{ if $featured_image }}
{{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}}
{{ $featured_image_class := site.Params.featured_image_class | compare.Default "cover bg-top" }}
@@ -8,14 +9,7 @@
<div class="{{ $cover_dimming_class }}">
{{ partials.Include "site-navigation.html" .}}
<div class="{{ $header_section_class }}">
- <h1 class="f2 f-subheadline-l fw2 white-90 mb0 lh-title">
- {{ .Title | compare.Default .Site.Title }}
- </h1>
- {{ with .Params.description }}
- <h2 class="fw1 f5 f3-l white-80 measure-wide-l center mt3">
- {{ . }}
- </h2>
- {{ end }}
+ {{ partials.Include "header/content.html" $header }}
</div>
</div>
</header>
@@ -25,14 +19,7 @@
{{ partials.Include "site-navigation.html" . }}
{{ $header_section_class := .Param "header_section_class" | compare.Default "tc-l pv3 ph3 ph4-ns" }}
<div class="{{ $header_section_class }}">
- <h1 class="f2 f-subheadline-l fw2 light-silver mb0 lh-title">
- {{ .Title | compare.Default .Site.Title }}
- </h1>
- {{ with .Params.description }}
- <h2 class="fw1 f5 f3-l white-80 measure-wide-l center lh-copy mt3 mb4">
- {{ . }}
- </h2>
- {{ end }}
+ {{ partials.Include "header/content.html" $header }}
</div>
</div>
</header>
diff --git a/layouts/_partials/site-navigation.html b/layouts/_partials/site-navigation.html
index 451e53f..ba55632 100644
--- a/layouts/_partials/site-navigation.html
+++ b/layouts/_partials/site-navigation.html
@@ -1,6 +1,9 @@
{{- /*
Site header navigation.
+ The brand link, languages, menu, and social links are header components:
+ each one renders through the header hooks (see `header/component.html`).
+
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
@@ -12,140 +15,29 @@
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.
-*/ -}}
-{{- define "_partials/AnankeMenuCurrent.html" -}}
- {{- $current := "" -}}
- {{- if .page.IsMenuCurrent "main" .entry -}}
- {{- $current = "page" -}}
- {{- else if .page.HasMenuCurrent "main" .entry -}}
- {{- $current = "true" -}}
- {{- end -}}
- {{- return $current -}}
-{{- 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" 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 }}
-{{- $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="ananke-submenu-link {{ $classes.submenu_link }}" href="{{ .URL }}" title="{{ lang.Translate "pageTitle" . }}"{{ with $current }} aria-current="{{ . }}"{{ end }}>{{ .Name }}</a>
- {{- else }}
- <span class="ananke-submenu-link {{ $classes.submenu_link }}">{{ .Name }}</span>
- {{- end }}
- {{- with .Children }}
- {{ partials.Include "AnankeSubmenu.html" (dict "page" $page "entries" . "classes" $classes) }}
- {{- end }}
- </li>
- {{- end }}
-</ul>
-{{- end -}}
-{{- $classes := partials.Include "AnankeNavigationClasses.html" . -}}
+{{- $classes := partials.Include "func/header/GetNavigationClasses.html" . -}}
+{{- $header := collections.Dictionary
+ "page" .
+ "region" "navigation"
+ "featured_image" (partials.Include "func/GetFeaturedImage.html" .)
+ "classes" $classes
+-}}
<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>
+ {{ partials.Include "header/component.html" (collections.Dictionary "name" "logo" "context" $header) }}
{{- 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" -}}
+ {{- partials.Include "header/menu-toggle-icon.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="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="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. 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="ananke-nav-item ananke-has-submenu {{ $classes.item }}">
- {{- if .URL }}
- <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 {{ $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="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 "classes" $classes) }}
- </li>
- {{- end }}
- {{ end }}
- </ul>
- {{ end }}
- {{ partials.IncludeCached "social/follow.html" . }}
+ {{ partials.Include "header/component.html" (collections.Dictionary "name" "languages" "context" $header) }}
+ {{ partials.Include "header/component.html" (collections.Dictionary "name" "menu" "context" $header) }}
+ {{ partials.Include "header/component.html" (collections.Dictionary "name" "social" "context" $header) }}
{{- with partials.Include "hook.html" (dict "hook" "navigation-end" "context" .) | strings.TrimSpace }}
<div class="ananke-nav-end">{{ . | safeHTML }}</div>
{{- end }}
--
Gitblit v1.10.0