aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-card.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/author-card.html')
-rw-r--r--themes/default/layouts/partials/author-card.html103
1 files changed, 69 insertions, 34 deletions
diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html
index 3e4bcca..561fef3 100644
--- a/themes/default/layouts/partials/author-card.html
+++ b/themes/default/layouts/partials/author-card.html
@@ -1,46 +1,81 @@
-{{- $path := print "public/" .Data.user "/media/profile/picture.png" -}}
-{{- $image := resources.Get $path -}}
-{{- $dimensions := "96x96" -}}
-{{- $404image := resources.Get "data/media/404.png" -}}
+{{- $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>
- <micro-summary>
- <micro-thumbnail>
+ <header>
<figure>
- <a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/#">
+ <a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/">
<picture>
- {{- with $image }}
- {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Data.user "/" (path.Base .)) }}
- <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
- {{- end }}
+ {{- with $sourceset -}}
+ <source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" />
+ {{- end -}}
<img
- alt="{{ .Data.name }}"
- {{- if fileExists $path }}
- {{ with $image }}
- {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $.Data.user "/" (path.Base .))).Fit $dimensions -}}
- width="{{ $image.Width }}"
- height="{{ $image.Height }}"
- src="{{ $image.RelPermalink }}"
- {{- end }}
- {{ else }}
- width="{{ $404image.Width }}"
- height="{{ $404image.Height }}"
- src="{{ $404image.RelPermalink }}"
- {{- end -}}
+ width="{{ or $width "64" }}"
+ height="{{ or $height "64" }}"
+ src="{{ print ("" | absURL) $source }}"
+ alt="{{ $alternate }}"
/>
</picture>
</a>
</figure>
- </micro-thumbnail>
- <micro-header>
- <h2><b>{{ .Data.name }}</b></h2>
- <h3><a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}/#">@{{ .Data.user }}</a></h3>
- </micro-header>
- <a title="Follow with RSS Reader" href="{{ "" | absURL }}/{{ .Data.user }}/rss.xml">
- {{ safeHTML (readFile (print (partial "function-paths-static.html") "/icons/feather/rss.svg")) }}
- <span>Follow</span>
- </a>
- </micro-summary>
+ </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>