Rename Docs menu #763
Replies: 3 comments 9 replies
-
Make sure to have your identifiers set right — see also https://getdoks.org/docs/how-to/pages-and-menus/menus/#add-to-docs-menu |
Beta Was this translation helpful? Give feedback.
-
I try this:
But it doesn't work |
Beta Was this translation helpful? Give feedback.
-
I tried to define my own navi-link activation rule. activate conditions:
excerpt<ul class="nav flex-column flex-md-row ms-md-n3">
{{- $current := . -}}
{{- $section := $current.Section -}}
{{ range .Site.Menus.main -}}
{{ $url := print .URL "/" }}
{{ $url := $url | safeURL | urlize | relURL }}
{{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
{{- $active = or $active (and (eq .Identifier $current.Section) (ne .Identifier "") (ne $current.Section "")) -}}
{{- $active = or $active (and (eq .Identifier "blog") (eq $current.Section "contributors")) -}}
{{- $active = or $active (eq $url $current.RelPermalink) -}}
{{ if .HasChildren }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle ps-0 py-1{{ if $active }} active{{ end }}" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ .Name }}
<span class="dropdown-caret"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg></span>
</a>
<ul class="dropdown-menu dropdown-menu-main shadow rounded border-0" aria-labelledby="navbarDropdownMenuLink">
{{ range .Children -}}
{{$url := print .URL "/" }}
{{$url := $url | safeURL | urlize | relURL }}
{{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
{{- $active = eq $url $current.RelPermalink -}}
<li>
<a class="dropdown-item{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}"{{ if $active }} aria-current="true"{{ end }}>{{ .Name }}</a>
</li>
{{ end -}}
</ul>
</li>
{{ else }}
<li class="nav-item">
<a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end -}}
</ul> (And I made changes so that the top level menu and the child are highlighted independently while I'm at it.) I sent PR to your repository. Is this close to the behavior you want? |
Beta Was this translation helpful? Give feedback.
-
How i can rename Docs menu item? If i change name param in menus.{lang}.toml file, then menu item does not marked as active item when i browse docs
Beta Was this translation helpful? Give feedback.
All reactions