mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
yesterday 98cea2ca8c5d3c425597f4fdfeca33039e87bc78
fix: apply configured social colours on hover for follow and share (#861)

The generated per-network hover CSS never matched any networks: it filtered
the social networks map with `where ... "slug" "in"`, which yields nothing for
a Params map, so no per-network rules were emitted and icons kept the default
grey on hover.

Build the rules by ranging the configured network slugs and indexing into the
networks map (as the follow/share partials already do), covering the union of
follow and share networks, and set both `color` and `fill` so the monochrome
SVG icons pick up the configured brand colour on hover.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 files modified
29 ■■■■ changed files
layouts/_partials/site-style.html 29 ●●●● patch | view | raw | blame | history
layouts/_partials/site-style.html
@@ -34,16 +34,31 @@
{{/* Generated social network hover colours */}}
{{- with site.Params.ananke.social -}}
  {{- $config := . -}}
  {{- $networks := $config.follow.networks | default collections.Slice -}}
  {{- $setups := collections.Where $config.networks "slug" "in" $networks -}}
  {{- with $setups -}}
  {{/* Cover both the follow and the share links, since either can render an
       icon that should pick up its configured brand colour on hover. */}}
  {{- $follow_networks := collections.Slice -}}
  {{- with $config.follow -}}
    {{- $follow_networks = .networks | default collections.Slice -}}
  {{- end -}}
  {{- $share_networks := collections.Slice -}}
  {{- with $config.share -}}
    {{- $share_networks = .networks | default collections.Slice -}}
  {{- end -}}
  {{- $networks := collections.Union $follow_networks $share_networks -}}
  {{- with $networks -}}
    {{- $socials_rules := collections.Slice -}}
    {{- range $service := . -}}
      {{- with $service.color -}}
        {{- $rule := fmt.Printf ".ananke-socials a.%s:hover {\n  color: %s !important;\n}" $service.slug . -}}
        {{- $socials_rules = $socials_rules | collections.Append $rule -}}
    {{- range $slug := . -}}
      {{- with collections.Index $config.networks $slug -}}
        {{- with .color -}}
          {{- $color := . -}}
          {{/* Set both `color` and `fill` so monochrome SVG icons (which inherit
               `fill: currentColor`) and any other markup react to the hover. */}}
          {{- $rule := fmt.Printf ".ananke-socials a.%s:hover {\n  color: %s !important;\n  fill: %s !important;\n}" $slug $color $color -}}
          {{- $socials_rules = $socials_rules | collections.Append $rule -}}
        {{- end -}}
      {{- end -}}
    {{- end -}}