aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-card.html
blob: 561fef3354c43ee2d370ea1f1c5245ec2c11ef85 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{{- $metadata := print "public/" .Data.user "/author.json" -}}
{{- $date := .Date | time.Format "Mon Jan 2 2006" -}}

{{- $host := (urls.Parse ("" | absURL)).Host -}}

{{- if not $host -}}
  {{- $host = "localhost" -}}
{{- end -}}

{{- $alternate := .Data.name -}}
{{- $width := "" -}}
{{- $height := "" -}}
{{- $source := "" -}}
{{- $sourceset := "" -}}

{{- $source = print "/" (partial "function-paths.html").media "/" .Data.user "/" .Data.user "-profile" (path.Ext .Data.picture.profile) -}}
{{- $sourceset = print "/" (partial "function-paths.html").media "/" .Data.user "/" .Data.user "-profile.webp" -}}

{{- with $metadata := resources.Get $metadata -}}
  {{- with $content := $metadata.Content -}}
    {{- $metadata = $content | transform.Unmarshal -}}
    {{- $width = $metadata.picture.profileWidth -}}
    {{- $height = $metadata.picture.profileHeight -}}
  {{- end -}}
{{- end -}}

{{- if or
  (not (path.Ext .Data.picture.profile))
  (not (fileExists (print "public/" (partial "function-paths.html").media "/" .Data.user)))
-}}
  {{- $source = "/data/media/404.png" -}}
  {{- $sourceset = "" -}}
{{- end -}}

{{- if not .Date -}}
  {{- $date = "Inactive" -}}
{{- end -}}

<micro-author>
  <micro-card>
    <header>
      <figure>
        <a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/">
          <picture>
            {{- with $sourceset -}}
             <source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" />
            {{- end -}}
            <img
              width="{{ or $width "64" }}"
              height="{{ or $height "64" }}"
              src="{{ print ("" | absURL) $source }}"
              alt="{{ $alternate }}"
            />
          </picture>
        </a>
      </figure>
    </header>
    <article>
      <h2>
        <b>{{ .Data.name }}</b>
      </h2>
      <h3>
        <a data-hover="" title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/">
          {{ .Data.user }}@{{ $host }}
        </a>
      </h3>
      <time
        data-type="default"
        title="{{ .Date | time.Format "Monday January 2 2006 at 15:04:05 MST" }}"
        datetime="{{ .Date | time.Format "2006-01-02T15:04:05Z" }}"
      >
        {{ $date }}
      </time>
    </article>
    <p>{{ .Data.description | markdownify | plainify | htmlUnescape | truncate 60 "..." }}</p>
    <a title="Follow with RSS Reader" href="{{ "" | absURL }}/{{ .Data.user }}/rss.xml">
      {{ safeHTML (readFile (print (partial "function-paths.html").static "/icons/tabler/rss.svg")) }}
      <span>Feed</span>
    </a>
  </micro-card>
</micro-author>