Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -70,6 +72,7 @@ params:
source: "Summary" # "Summary" | "meta_description"
truncate: 125
level_3:
dropdown: false
summary:
active: false
source: "Summary" # "Summary" | "meta_description"
Expand Down
41 changes: 0 additions & 41 deletions layouts/partials/commons/menu-dropdown.html

This file was deleted.

136 changes: 27 additions & 109 deletions layouts/partials/commons/menu.html
Original file line number Diff line number Diff line change
@@ -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 -}}

<ul class="{{ if $level }}nav-level-{{ $level }}{{ end }} {{ .class }}">
{{ 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")) -}}
<li {{ with $item_class }}class="{{ . }}"{{ end }}>

{{- if ne .kind "blank" -}}
<a href="{{ .target }}" {{ with $link_class }} class="{{ . }}" {{ end }} {{ safeHTMLAttr $attributes }} {{ safeHTMLAttr $title_attribute }}>
{{ .title | markdownify }}
</a>
{{ partial "GetMenuSummary" (dict
"summary" $level_options.summary
"path" .path
) }}
{{- else -}}
{{ if gt .level 1 }}
{{ $link_class = printf "%s disabled" $link_class }}
{{ end }}
<span {{ with $link_class }}class="{{ . }}"{{ end }} {{ safeHTMLAttr $attributes }}>{{ .title | markdownify }}</span>
{{- 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 -}}
</li>
{{- end -}}
{{ end -}}

{{ if and site.Params.search.active (in site.Params.search.positions $kind) }}
<li class="nav-search">
{{ partial "commons/search/button.html" $kind }}
</li>
{{ 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 }}
<ul class="{{ with $level }}nav-level-{{ . }}{{ end }} {{ .class }}">
{{ 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 }}
</ul>
{{ partial "commons/menu/search" (dict
"kind" $kind
"context" $context
) }}
{{ partial "commons/menu/i18n" (dict
"kind" $kind
"context" $context
) }}
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
{{ $text := "" }}

{{ if and $page $summary.active }}

{{ if eq $summary.source "Summary" }}
{{ $text = $page.Params.Summary }}
{{ else if eq $summary.source "meta_description" }}
{{ with index $page.Params "meta_description" }}
{{ $text = printf "<p>%s</p>" . }}
{{ end }}
{{ end }}

{{ if $text }}
{{ $text = partial "GetTruncatedText" (dict
"text" $text
"length" $summary.truncate
) }}
{{ end }}

{{ end }}

{{ return $text }}
6 changes: 6 additions & 0 deletions layouts/partials/commons/menu/i18n.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ if in site.Params.i18n.positions .kind }}
{{ partial "commons/i18n.html" (dict
"position" .kind
"context" .context
) }}
{{ end }}
31 changes: 31 additions & 0 deletions layouts/partials/commons/menu/item.html
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions layouts/partials/commons/menu/item/children.html
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 18 additions & 0 deletions layouts/partials/commons/menu/item/children/dropdown.html
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="dropdown-menu is-titled">
<div class="container">
<div class="dropdown-menu-heading">
{{ if .parent.target }}
<a href="{{ .parent.target }}" class="dropdown-menu-title">{{ .parent.title }}</a>
{{ else }}
<p class="dropdown-menu-title">{{ .parent.title }}</p>
{{ end }}
{{ if .parent.path }}
{{ with partial "commons/menu/helpers/GetSummary" (dict
"summary" .summary
"path" .parent.path
) }}
<div class="dropdown-menu-summary">{{ . }}</div>
{{ end }}
{{ end }}
</div>
{{ partial "commons/menu/ul" (dict
"items" .items
"level" .level
"options" .options
"context" .context
) }}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="dropdown-menu">
{{ partial "commons/menu/ul" (dict
"items" .items
"level" .level
"options" .options
"context" .context
) }}
</div>
29 changes: 29 additions & 0 deletions layouts/partials/commons/menu/item/title.html
Original file line number Diff line number Diff line change
@@ -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" }}
<span{{ with $link_class }} class="{{ . }}"{{ end }} {{ safeHTMLAttr $attributes }}>
{{ .item.title | markdownify }}
</span>
{{ else }}
<a href="{{ .item.target }}" {{ with $link_class }} class="{{ . }}"{{ end }} {{ safeHTMLAttr $attributes }} {{ safeHTMLAttr $title_attribute }}>
{{ .item.title | markdownify }}
</a>
{{ if .level_options }}
{{ partial "commons/menu/helpers/GetSummary" (dict
"summary" .level_options.summary
"path" .path
) }}
{{ end }}
{{ end }}
Loading