aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/shortcodes/link.html
blob: efcdf78706881beec82b78589b0058da598d74aa (plain)
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
{{- $source := default "https://example.com/" (.Get "source" | default (.Get 0)) -}}

{{- $host := $source -}}

{{- with (urls.Parse $source).Host -}}
  {{- $host = . -}}
{{- end -}}

{{- $favicon := partial "function-favicon-domain.html" $host -}}

{{- $image := partial "function-fetch-favicons.html"
  (dict
    "Source" $favicon
    "Infix"  ($host | anchorize)
  )
-}}

<link-card>
  <a href="{{ $source }}">
    <img
      loading="lazy"
      alt="{{ $host }}"
      title="{{ $host }}"
      height="{{ $image.Height }}"
      width="{{ $image.Width }}"
      src="{{ $image.Permalink }}"
    />
  </a>
  <article>
    <h2>{{ $host }}</h2>
    <a href="{{ $source }}">
      {{ $source }}
    </a>
  </article>
</link-card>