Skip to content

Commit

Permalink
Merge pull request #1021 from gethinode/develop
Browse files Browse the repository at this point in the history
Add plain argument to navbar-item
  • Loading branch information
markdumay authored Jul 1, 2024
2 parents 91090aa + 9a0f907 commit 1ec9568
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions data/structures/navbar-item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ arguments:
comment: >-
Flag to indicate if an external link should open in a new tab, defaults
to setting `main.externalLinks.tab` in the site's parameters.
plain:
type: bool
optional: true
comment: >-
Renders the navigation item as plain item, ignoring any children.
7 changes: 4 additions & 3 deletions layouts/partials/assets/navbar-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{{- $page := .page -}}
{{- $menu := .menu -}}
{{- $parent := .parent -}}
{{- $plain := .plain | default false -}}
{{- $class := .class -}}
{{- $cue := .cue | default site.Params.main.externalLinks.cue -}}
{{- $tab := .tab | default site.Params.main.externalLinks.tab -}}
Expand Down Expand Up @@ -56,7 +57,7 @@
{{- $mainNav = urlize (lower $parent.Name) -}}
{{- $childNav = urlize (lower $menu.Name) -}}
{{- $anchorClass = "dropdown-item" -}}
{{- else if $menu.HasChildren -}}
{{- else if and (not $plain) $menu.HasChildren -}}
{{- $anchorClass = "nav-link dropdown-toggle" -}}
{{- $button = " role=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"" -}}
{{- else -}}
Expand All @@ -78,7 +79,7 @@
"size" "sm"
)}}
{{ else }}
<a class="{{ $anchorClass }}{{ if $isActive }} active{{ end }}{{ with $class }} {{. }}{{ end }}"
<a class="{{ $anchorClass }}{{ if $isActive }} active{{ end }}{{ with $class }} {{ . }}{{ end }}"
{{ if $isIcon }}aria-label="{{ $menu.Name }}"{{ end }}
data-nav="main" data-nav-main="{{ $mainNav }}"{{ with $childNav }} data-nav-child="{{ . }}"{{ end }}
href="{{ $menuURL }}{{ $params | safeHTMLAttr }}"{{ with $externalHref }} {{ . | safeHTMLAttr }}{{ end }} {{ $button | safeHTMLAttr }}>
Expand All @@ -90,7 +91,7 @@
{{ partial "assets/icon.html" (dict "icon" (string .) )}}
{{ end }}
{{ end -}}
<span {{ if $isActive }} class="active"{{ end }}>{{ if not $isIcon }}{{ $menu.Name }}{{ end }}</span>
<span {{ if $isActive }} class="active"{{ end }}>{{ if or (not $isIcon) $plain }}{{ $menu.Name }}{{ end }}</span>
{{- with $menu.Post }}{{ . }}{{ end -}}
{{- if not $isIcon }}&nbsp;{{ $suffix }}{{ end -}}
</a>
Expand Down

0 comments on commit 1ec9568

Please sign in to comment.