]> danix's work - danix.xyz-2.git/commitdiff
feat: add active state highlight to desktop nav links
authorDanilo M. <redacted>
Wed, 22 Apr 2026 09:40:47 +0000 (11:40 +0200)
committerDanilo M. <redacted>
Wed, 22 Apr 2026 09:40:47 +0000 (11:40 +0200)
Apply same active-page detection logic used in hamburger menu to desktop
navigation. Desktop nav now shows purple accent color + bold font and
aria-current=page attribute when viewing the linked page. Works for both
EN and IT languages.

themes/danix-xyz-hacker/layouts/partials/header.html

index 739c77671968df6d1ce28c8e947bdd7cf6624b21..914e64595a2e31580d4177a840d5f9fc3770b817 100644 (file)
 
     <!-- Desktop menu (hidden on mobile) -->
     <div class="hidden md:flex items-center gap-8">
+      {{ $currentPath := strings.TrimSuffix "/" .RelPermalink }}
       {{ range .Site.Menus.main }}
-        <a href="{{ .URL }}" class="text-sm hover:text-accent transition-colors">
+        {{ $menuPath := strings.TrimSuffix "/" .URL }}
+        {{ $isActive := eq $menuPath $currentPath }}
+        <a
+          href="{{ .URL }}"
+          class="text-sm transition-colors {{ if $isActive }}text-accent font-bold{{ else }}hover:text-accent{{ end }}"
+          {{ if $isActive }}aria-current="page"{{ end }}
+        >
           {{ i18n .Name }}
         </a>
       {{ end }}