diff --git a/hugo.yaml b/hugo.yaml
index 6186c212a..46e4d2ec0 100644
--- a/hugo.yaml
+++ b/hugo.yaml
@@ -54,11 +54,13 @@ params:
menu:
primary:
level_1:
+ dropdown: true
summary:
active: false
source: "Summary" # "Summary" | "meta_description"
truncate: 125
level_2:
+ dropdown: false
summary:
active: false
source: "Summary" # "Summary" | "meta_description"
@@ -70,6 +72,7 @@ params:
source: "Summary" # "Summary" | "meta_description"
truncate: 125
level_3:
+ dropdown: false
summary:
active: false
source: "Summary" # "Summary" | "meta_description"
diff --git a/layouts/partials/commons/menu-dropdown.html b/layouts/partials/commons/menu-dropdown.html
deleted file mode 100644
index 700692644..000000000
--- a/layouts/partials/commons/menu-dropdown.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{{- $parent := .parent -}}
-{{- $level := .level -}}
-{{- $options := .options -}}
-{{- $level_options := index $options (printf "level_%d" $level) -}}
-{{- $slug := anchorize .parent.title -}}
-{{- $submenu := .submenu -}}
-{{- $class := "dropdown-menu" -}}
-
-{{ if $level_options.title.active }}
- {{ $class = printf "%s is-titled" $class }}
-{{ end }}
-
-
- {{- with $level_options.title }}
- {{ if .active }}
-
-
-
- {{ $submenu }}
-
- {{ else -}}
- {{ $submenu }}
- {{ end -}}
- {{ end }}
-
diff --git a/layouts/partials/commons/menu.html b/layouts/partials/commons/menu.html
index c4adc2e00..d7dd93faa 100644
--- a/layouts/partials/commons/menu.html
+++ b/layouts/partials/commons/menu.html
@@ -1,114 +1,32 @@
{{ $kind := .kind }}
-{{ $items := .items }}
-{{ $context := .context }}
-{{ if $kind }}
- {{ $menu := partial "GetMenu" $kind }}
- {{ $items = $menu.items }}
-{{ end }}
-{{- $level := .level -}}
-{{- $stop := .stop -}}
-
+{{ $dropdown := .dropdown }}
{{ $options := .options }}
-{{ if $kind }}
- {{- $options = index site.Params.menu $kind -}}
-{{ end }}
-{{- $level_options := index $options (printf "level_%d" $level) -}}
-{{- $dropdown := .dropdown -}}
-
-
- {{ range $items -}}
- {{- $slug := anchorize .title -}}
- {{- $item_class := "" -}}
- {{- $link_class := "" -}}
- {{- $attributes := "" -}}
- {{- $title_attribute := printf "title=\"%s\"" .title -}}
- {{- $has_dropdown := false -}}
-
- {{ if eq $context.RelPermalink .target }}
- {{ $link_class = "active" }}
- {{ end }}
-
- {{ if eq $kind "social" }}
- {{- $item_class = printf .title | lower -}}
- {{ end }}
-
- {{- if gt (len .children) 0 -}}
- {{- $item_class = printf "%s has-children" $item_class -}}
- {{ range .children -}}
- {{- if eq $context.RelPermalink .target }}
- {{ $link_class = printf "%s %s" $link_class "has-children-active" }}
- {{ end }}
- {{ end -}}
- {{- end -}}
-
- {{- if and (gt (len .children) 0) $dropdown (eq $level 1) -}}
- {{- $has_dropdown = true -}}
- {{- $attributes = printf "id=\"dropdown-%s\" role=\"button\" aria-expanded=\"false\" tabindex=\"0\"" $slug -}}
- {{- end -}}
-
- {{- if .new_tab -}}
- {{- $extern_link := i18n "commons.link.blank" -}}
- {{- $title_attribute = printf "title=\"%s - %s\"" .title $extern_link -}}
- {{- $attributes = " target=\"_blank\" rel=\"noreferrer\"" -}}
- {{- end -}}
-
- {{ if $level_options.summary.active }}
- {{ $item_class = printf "%s with-summary" $item_class }}
- {{ end }}
-
- {{- if or (ne $stop 1) (and (eq $stop 1) (ne .kind "blank")) -}}
- -
-
- {{- if ne .kind "blank" -}}
-
- {{ .title | markdownify }}
-
- {{ partial "GetMenuSummary" (dict
- "summary" $level_options.summary
- "path" .path
- ) }}
- {{- else -}}
- {{ if gt .level 1 }}
- {{ $link_class = printf "%s disabled" $link_class }}
- {{ end }}
- {{ .title | markdownify }}
- {{- end -}}
-
- {{- if and (ne $stop $level) (gt (len .children) 0) -}}
- {{- $next_level := add $level 1 -}}
- {{- $submenu := partial "commons/menu.html" (dict
- "items" .children
- "level" $next_level
- "options" $options
- "context" $context
- ) -}}
- {{- if $has_dropdown }}
- {{ partial "commons/menu-dropdown" (dict
- "parent" .
- "level" $next_level
- "options" $options
- "submenu" $submenu
- ) }}
- {{- else -}}
- {{- $submenu -}}
- {{- end -}}
- {{- end -}}
-
- {{- end -}}
- {{ end -}}
-
- {{ if and site.Params.search.active (in site.Params.search.positions $kind) }}
- -
- {{ partial "commons/search/button.html" $kind }}
-
- {{ end }}
- {{ if eq $kind "legal" }}
- {{ $kind = "footer" }}
- {{ end }}
- {{ if in site.Params.i18n.positions $kind }}
- {{ partial "commons/i18n.html" (dict
+{{ $level := .level }}
+{{ $stop := .stop }}
+{{ $menu := partial "GetMenu" $kind }}
+{{ $items := $menu.items }}
+{{ $options = index site.Params.menu $kind }}
+{{ $level_options := index $options (printf "level_%d" $level) }}
+{{ $context := .context }}
+
+ {{ range $items }}
+ {{ partial "commons/menu/item" (dict
+ "item" .
+ "kind" $kind
+ "dropdown" $dropdown
+ "options" $options
+ "level" $level
+ "level_options" $level_options
+ "stop" $stop
"context" $context
- "position" $kind
) }}
{{ end }}
-
+ {{ partial "commons/menu/search" (dict
+ "kind" $kind
+ "context" $context
+ ) }}
+ {{ partial "commons/menu/i18n" (dict
+ "kind" $kind
+ "context" $context
+ ) }}
+
\ No newline at end of file
diff --git a/layouts/partials/GetMenuSummary b/layouts/partials/commons/menu/helpers/GetSummary.html
similarity index 99%
rename from layouts/partials/GetMenuSummary
rename to layouts/partials/commons/menu/helpers/GetSummary.html
index 3151ad8da..271e80349 100644
--- a/layouts/partials/GetMenuSummary
+++ b/layouts/partials/commons/menu/helpers/GetSummary.html
@@ -4,7 +4,6 @@
{{ $text := "" }}
{{ if and $page $summary.active }}
-
{{ if eq $summary.source "Summary" }}
{{ $text = $page.Params.Summary }}
{{ else if eq $summary.source "meta_description" }}
@@ -12,14 +11,12 @@
{{ $text = printf "%s
" . }}
{{ end }}
{{ end }}
-
{{ if $text }}
{{ $text = partial "GetTruncatedText" (dict
"text" $text
"length" $summary.truncate
) }}
{{ end }}
-
{{ end }}
{{ return $text }}
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/i18n.html b/layouts/partials/commons/menu/i18n.html
new file mode 100644
index 000000000..a091a816e
--- /dev/null
+++ b/layouts/partials/commons/menu/i18n.html
@@ -0,0 +1,6 @@
+{{ if in site.Params.i18n.positions .kind }}
+ {{ partial "commons/i18n.html" (dict
+ "position" .kind
+ "context" .context
+ ) }}
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item.html b/layouts/partials/commons/menu/item.html
new file mode 100644
index 000000000..0b8116f5d
--- /dev/null
+++ b/layouts/partials/commons/menu/item.html
@@ -0,0 +1,31 @@
+{{- $item := .item -}}
+{{- $context := .context -}}
+{{- $is_active := eq $context.RelPermalink $item.target -}}
+{{- $item_class := "" -}}
+{{ with .level_options }}
+ {{ if .summary.active }}
+ {{ $item_class = printf "%s with-summary" $item_class }}
+ {{ end }}
+{{ end }}
+
+{{ if $item.children }}
+ {{ partial "commons/menu/item/with-children" (dict
+ "item" $item
+ "is_active" $is_active
+ "item_class" $item_class
+ "level" .level
+ "level_options" .level_options
+ "options" .options
+ "dropdown" .dropdown
+ "context" .context
+ ) }}
+{{ else }}
+ {{ partial "commons/menu/item/without-children" (dict
+ "item" $item
+ "is_active" $is_active
+ "item_class" $item_class
+ "level" .level
+ "level_options" .level_options
+ "context" .context
+ ) }}
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/children.html b/layouts/partials/commons/menu/item/children.html
new file mode 100644
index 000000000..f2a42b734
--- /dev/null
+++ b/layouts/partials/commons/menu/item/children.html
@@ -0,0 +1,16 @@
+{{ if .has_dropdown }}
+ {{ partial "commons/menu/item/children/dropdown" (dict
+ "parent" .parent
+ "items" .items
+ "level" .level
+ "options" .options
+ "context" .context
+ ) }}
+{{ else }}
+ {{ partial "commons/menu/ul" (dict
+ "items" .items
+ "level" .level
+ "options" .options
+ "context" .context
+ ) }}
+{{ end }}
diff --git a/layouts/partials/commons/menu/item/children/dropdown.html b/layouts/partials/commons/menu/item/children/dropdown.html
new file mode 100644
index 000000000..df45cc3de
--- /dev/null
+++ b/layouts/partials/commons/menu/item/children/dropdown.html
@@ -0,0 +1,18 @@
+{{ $level_options := index .options (printf "level_%d" .level) }}
+
+{{ if $level_options.title.active }}
+ {{ partial "commons/menu/item/children/dropdown/with-title" (dict
+ "parent" .parent
+ "items" .items
+ "level" .level
+ "options" .options
+ "context" .context
+ ) }}
+{{ else }}
+ {{ partial "commons/menu/item/children/dropdown/without-title" (dict
+ "items" .items
+ "level" .level
+ "options" .options
+ "context" .context
+ ) }}
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/children/dropdown/with-title.html b/layouts/partials/commons/menu/item/children/dropdown/with-title.html
new file mode 100644
index 000000000..c96cef61c
--- /dev/null
+++ b/layouts/partials/commons/menu/item/children/dropdown/with-title.html
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/children/dropdown/without-title.html b/layouts/partials/commons/menu/item/children/dropdown/without-title.html
new file mode 100644
index 000000000..6ca6b84f4
--- /dev/null
+++ b/layouts/partials/commons/menu/item/children/dropdown/without-title.html
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/title.html b/layouts/partials/commons/menu/item/title.html
new file mode 100644
index 000000000..36056f27a
--- /dev/null
+++ b/layouts/partials/commons/menu/item/title.html
@@ -0,0 +1,29 @@
+{{ $attributes := .attributes }}
+{{ $link_class := .link_class }}
+{{ $title_attribute := printf "title=\"%s\"" .item.title }}
+
+{{ if .is_active }}
+ {{ $link_class = "active" }}
+{{ end }}
+
+{{ if .item.new_tab -}}
+ {{ $external_link := i18n "commons.link.blank" -}}
+ {{ $attributes = " target=\"_blank\" rel=\"noreferrer\"" }}
+ {{ $title_attribute = printf "title=\"%s - %s\"" .item.title $external_link }}
+{{ end }}
+
+{{ if eq .item.kind "blank" }}
+
+ {{ .item.title | markdownify }}
+
+{{ else }}
+
+ {{ .item.title | markdownify }}
+
+ {{ if .level_options }}
+ {{ partial "commons/menu/helpers/GetSummary" (dict
+ "summary" .level_options.summary
+ "path" .path
+ ) }}
+ {{ end }}
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/with-children.html b/layouts/partials/commons/menu/item/with-children.html
new file mode 100644
index 000000000..443440f71
--- /dev/null
+++ b/layouts/partials/commons/menu/item/with-children.html
@@ -0,0 +1,32 @@
+{{ $context := .context }}
+{{ $link_class := .link_class }}
+{{ $attributes := "" }}
+{{ if in .item.descendants_targets $context.RelPermalink }}
+ {{ $link_class = printf "%s %s" $link_class "has-children-active" }}
+{{ end -}}
+{{ if .level_options.dropdown }}
+ {{ $attributes = printf "id=\"dropdown-%s\" role=\"button\" aria-expanded=\"false\" tabindex=\"0\"" .item.slug -}}
+{{ end }}
+
+
+ {{ partialCached "commons/menu/item/title" (dict
+ "item" .item
+ "level" .level
+ "is_active" .is_active
+ "link_class" $link_class
+ "attributes" $attributes
+ "title_attribute" .title_attribute
+ "level_options" .level_options
+ "context" .context
+ ) .item .is_active $link_class }}
+ {{ if ne .stop .level }}
+ {{ partial "commons/menu/item/children" (dict
+ "items" .item.children
+ "parent" .item
+ "level" (add .level 1)
+ "options" .options
+ "has_dropdown" .level_options.dropdown
+ "context" .context
+ )}}
+ {{ end }}
+
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/item/without-children.html b/layouts/partials/commons/menu/item/without-children.html
new file mode 100644
index 000000000..58d982df2
--- /dev/null
+++ b/layouts/partials/commons/menu/item/without-children.html
@@ -0,0 +1,11 @@
+
+ {{ partialCached "commons/menu/item/title" (dict
+ "item" .item
+ "is_active" .is_active
+ "link_class" .link_class
+ "attributes" .attributes
+ "title_attribute" .title_attribute
+ "level_options" .level_options
+ "context" .context
+ ) .item .is_active .link_class }}
+
\ No newline at end of file
diff --git a/layouts/partials/commons/menu/search.html b/layouts/partials/commons/menu/search.html
new file mode 100644
index 000000000..006ef6421
--- /dev/null
+++ b/layouts/partials/commons/menu/search.html
@@ -0,0 +1,5 @@
+{{ if and site.Params.search.active (in site.Params.search.positions .kind) }}
+
+ {{ partial "commons/search/button.html" .kind }}
+
+{{ end }}
diff --git a/layouts/partials/commons/menu/ul.html b/layouts/partials/commons/menu/ul.html
new file mode 100644
index 000000000..db6d6401e
--- /dev/null
+++ b/layouts/partials/commons/menu/ul.html
@@ -0,0 +1,20 @@
+{{ $dropdown := .dropdown }}
+{{ $options := .options }}
+{{ $level := .level }}
+{{ $level_options := index $options (printf "level_%d" $level) }}
+{{ $stop := .stop }}
+{{ $context := .context }}
+
+
+ {{ range .items -}}
+ {{ partial "commons/menu/item" (dict
+ "item" .
+ "dropdown" $dropdown
+ "options" $options
+ "level" $level
+ "level_options" $level_options
+ "stop" $stop
+ "context" $context
+ ) }}
+ {{ end -}}
+
\ No newline at end of file
diff --git a/layouts/partials/footer/legals.html b/layouts/partials/footer/legals.html
index 6e3c878cf..4f1a8c830 100644
--- a/layouts/partials/footer/legals.html
+++ b/layouts/partials/footer/legals.html
@@ -5,7 +5,7 @@
{{ if not (in site.Params.i18n.positions "footer") }}
{{ $class = printf "%s without-i18n" $class }}
{{ end }}
- {{ partial "commons/menu.html" (dict
+ {{ partial "commons/menu" (dict
"kind" "legal"
"level" 1
"class" $class
diff --git a/layouts/partials/footer/social.html b/layouts/partials/footer/social.html
index b81157746..e74adfb55 100644
--- a/layouts/partials/footer/social.html
+++ b/layouts/partials/footer/social.html
@@ -1,7 +1,7 @@
{{ $menu := partial "GetMenu" "social" }}
{{ if $menu.items }}
- {{ partial "commons/menu.html" (dict
+ {{ partial "commons/menu" (dict
"kind" "social"
"level" 1
"class" "nav-social"
diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html
index 469dcf06c..a3b6764bf 100644
--- a/layouts/partials/header/header.html
+++ b/layouts/partials/header/header.html
@@ -8,7 +8,7 @@
{{ if $upper_menu.items }}