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

Regis Philibert
06.27.2022 b7b4d8775a8164018d65ae139f3b1821e6b6874c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{{/*
  socials/Get
  Returns the list of services registered by the user complemented by the built-in service default data if found.
 
  @author @regisphilibert
 
  @context Any (.)
 
  @access public
 
  @returns Slice of Maps
    - String (.name)
      String (.url)
      String (.label)
      String (.color)?
      Bool (.share)?
  @uses
     - partial
 
  @example - Go Template
    {{ with partialCached "socials/Get" context context }}
      {{ something = . }}
    {{ end }}
*/}}
{{ $socials := slice }}
{{ with partial "func/socials/GetRegisteredServices" "GetRegisteredServices" }}
  {{ range . }}
    {{ $service := . }}
    {{/* We fetch the default data and add it to service map if found */}}
    {{ with partialCached "func/socials/GetServiceData" .name .name }}
      {{ $service = merge . $service }}
    {{ end }}
    {{/* We fetch the icon and add it to service map fi found */}}
    {{ with partialCached "func/socials/GetServiceIcon" .name .name }}
      {{ $service = $service | merge (dict "icon" . ) }}
    {{ end }}
    {{/* In case no label is provided (on a non-built-in service) we add the .name as label to the service map */}}
    {{ with .label }}{{ else }}
      {{ $service = $service | merge (dict "label" $service.name ) }}
    {{ end }}
    {{ $socials = $socials | append $service }}
  {{ end }}
{{ end }}
 
{{ return $socials }}