From 7a048e3344c78ba758bda4ef9cf9e9dedcae39b7 Mon Sep 17 00:00:00 2001
From: alexisben <alex@noesya.coop>
Date: Tue, 14 Feb 2023 16:59:45 +0100
Subject: [PATCH] add active link without style

---
 assets/sass/_theme/_utils.sass               | 7 +++++--
 assets/sass/_theme/design-system/header.sass | 2 --
 assets/sass/_theme/design-system/nav.sass    | 6 +++---
 layouts/_default/baseof.html                 | 2 +-
 layouts/partials/commons/menu.html           | 5 +++++
 layouts/partials/header/header.html          | 2 ++
 6 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/assets/sass/_theme/_utils.sass b/assets/sass/_theme/_utils.sass
index 46ecb5d0..7d3258a8 100644
--- a/assets/sass/_theme/_utils.sass
+++ b/assets/sass/_theme/_utils.sass
@@ -39,13 +39,16 @@
 @function half($size)
     @return calc(#{$size} / 2)
 
-@mixin link($color: $link-color)
+@mixin link($color: $link-color, $unhover_decorated: true)
     color: $color
-    text-decoration-color: rgba($color, 0.3)
     text-decoration-line: underline
     text-decoration-thickness: 1px
     text-underline-offset: $link-underline-offset
     transition: text-decoration-color .3s ease
+    @if $unhover_decorated
+        text-decoration-color: rgba($color, 0.3)
+    @else 
+        text-decoration-color: transparent
     &:hover
         text-decoration-color: rgba($color, 1)
         text-decoration-thickness: 1px
diff --git a/assets/sass/_theme/design-system/header.sass b/assets/sass/_theme/design-system/header.sass
index eca47feb..a1156dea 100644
--- a/assets/sass/_theme/design-system/header.sass
+++ b/assets/sass/_theme/design-system/header.sass
@@ -24,8 +24,6 @@ header#document-header
             a:focus,
             a:active
                 color: inherit
-            a:not(:hover)
-                text-decoration-color: transparent
             span
                 color: $header-sticky-color
         @if $header-sticky-invert-logo
diff --git a/assets/sass/_theme/design-system/nav.sass b/assets/sass/_theme/design-system/nav.sass
index 44755c44..0b331bb3 100644
--- a/assets/sass/_theme/design-system/nav.sass
+++ b/assets/sass/_theme/design-system/nav.sass
@@ -17,7 +17,7 @@
     a,
     a:focus,
     a:active
-        @include link($header-color)
+        @include link($header-color, false)
     span
         color: $header-color
     ul
@@ -30,8 +30,8 @@
         cursor: pointer
         transition: text-decoration 0.15s
         display: block
-        &:not(:hover)
-            text-decoration-color: transparent
+        // &:not(:hover)
+        //     text-decoration-color: transparent
         &[aria-expanded]
             @include icon(caret, after)
                 margin-left: px2rem(5)
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index a9459f1b..8dd9d91d 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -15,7 +15,7 @@
   {{ $body_class = printf "%s %s" $body_class $pageclass }}
   <body class="{{ $body_class }}">
     {{- partial "header/accessibility.html" -}}
-    {{- partial "header/header.html" -}}
+    {{- partial "header/header.html" . -}}
     <main{{ if .Params.blocks }} class="page-with-blocks"{{ end }} id="main" tabindex="-1">
       {{- block "main" . }}{{- end }}
       {{- partial "hooks/before-main-end" . -}}
diff --git a/layouts/partials/commons/menu.html b/layouts/partials/commons/menu.html
index 34174849..6debde89 100644
--- a/layouts/partials/commons/menu.html
+++ b/layouts/partials/commons/menu.html
@@ -1,5 +1,6 @@
 {{- $kind := .kind -}}
 {{ $items := .items }}
+{{ $context := .context }}
 {{ if $kind }}
   {{ $items = partial "GetMenu" $kind }}
 {{ end }}
@@ -19,6 +20,9 @@
     {{- $attr := "" -}}
     {{- $attr_title := "" -}}
     {{- $hasDropdown := false -}}
+    {{ if eq $context.RelPermalink .target }}
+      {{ $linkClass = "active" }}
+    {{ end }}
     {{- if gt (len .children) 0 -}}
       {{- $itemClass = printf "%shas-children" $itemClass -}}
     {{- end -}}
@@ -47,6 +51,7 @@
                 (dict
                   "items" .children
                   "level" $nextLevel
+                  "context" $context
                 ) -}}
         {{- end -}}
         {{- if $hasDropdown -}}
diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html
index c047b701..cb886f37 100644
--- a/layouts/partials/header/header.html
+++ b/layouts/partials/header/header.html
@@ -1,3 +1,4 @@
+{{ $context := . }}
 <header id="document-header">
   <nav aria-label="{{ i18n "commons.menu.main" }}">
     <div class="container">
@@ -10,6 +11,7 @@
               "kind" "primary"
               "dropdown" true
               "level" 1
+              "context" .
             ) }}
       </div>
     </div>
-- 
GitLab