Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active menu in navbar doesn't highlight subsections / child pages #90

Open
h-enk opened this issue Jan 17, 2024 · 0 comments
Open

Active menu in navbar doesn't highlight subsections / child pages #90

h-enk opened this issue Jan 17, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@h-enk
Copy link
Member

h-enk commented Jan 17, 2024

Discussed in thuliteio/doks#1178

Originally posted by jollydodo January 16, 2024

Description

Minor change and not necessarily an issue/bug, but something that is normally different and would be a visual improvement. The navbar shows which section is active. This works fine, however, it does not take into account subsections. E.g. if I go to about and then 'about us', neither the parent nor the child have a highlighted element. This is also the case for blog posts for example. 'blog' only stays highlighted on the blog index and not on a single post.

On one of my previous websites I used the default Hugo method ".isMenuCurrent' to highlight the selected link. This method also supports ancestor/child pages out of the box with very simple code. I looked at the Doks implementation and this seems a bit more intricate.

Default Hugo approach:

{{ $currentPage := . }}
{{ range site.Menus.main }}
{{ if $currentPage.IsMenuCurrent .Menu . }}
{{ .Name }}
{{ else if $currentPage.HasMenuCurrent .Menu . }}
{{ .Name }}
{{ else }}
{{ .Name }}
{{ end }}
{{ end }}

Visualization

Scherm­afbeelding 2024-01-16 om 22 56 13

Picture of another Hugo site: stays highlighted even in a post that is part of 'portfolio' using default Hugo implementation. This tells the user that they are currently viewing an item that is part of 'portfolio'.

Doks: ( "open-inloop" is a child of "over")

Scherm­afbeelding 2024-01-16 om 22 56 35

Neither 'open-inloop' or 'over' is highlighted as active.

Preferred outcome:
Scherm­afbeelding 2024-01-16 om 22 56 43

This would make the appearance of the navbar more consistent, because it already works like this for the default 'docs' pages:
Scherm­afbeelding 2024-01-16 om 23 08 34

@h-enk h-enk transferred this issue from thuliteio/doks Jan 17, 2024
@h-enk h-enk added the enhancement New feature or request label Jan 17, 2024
@h-enk h-enk self-assigned this Mar 5, 2024
@h-enk h-enk modified the milestone: v1.5 Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant