diff options
Diffstat (limited to 'themes/default/layouts/partials/author-picture.html')
-rw-r--r-- | themes/default/layouts/partials/author-picture.html | 76 |
1 files changed, 42 insertions, 34 deletions
diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html index c269efc..01786e7 100644 --- a/themes/default/layouts/partials/author-picture.html +++ b/themes/default/layouts/partials/author-picture.html @@ -1,41 +1,49 @@ -{{- $file := "/profile/picture.png" -}} -{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} -{{- $image := resources.Get $path -}} -{{- $404image := resources.Get "data/media/404.png" -}} -{{- $dimensions := "160x160" -}} -{{- $author := partial "author-user.html" . }} +{{- $author := partial "function-authors-data.html" . -}} +{{- $metadata := print "public/" $author.user "/author.json" -}} -{{- with .Params.feed -}} +{{- $alternate := $author.name -}} +{{- $width := "" -}} +{{- $height := "" -}} +{{- $source := "" -}} +{{- $sourceset := "" -}} + +{{- with .Params.feed.favicon -}} + {{- $alternate = $.Params.feed.name -}} + {{- $width = "64" -}} + {{- $height = "64" -}} + {{- $source = print "/" (partial "function-paths.html").media "/favicon." ($.Params.feed.source | anchorize) ".png" -}} + {{- if not (fileExists (print "public/" $source)) -}} + {{- $source = $.Params.feed.favicon -}} + {{- end -}} + {{- $sourceset = "" -}} {{- else -}} - {{- with $image -}} - {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}} - <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> + {{- $source = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile) -}} + {{- $sourceset = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.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 }} + {{- else -}} + {{- $source = "/data/media/404.png" -}} + {{- $sourceset = "" -}} + {{- end -}} +{{- end -}} + +{{- if not (path.Ext $author.picture.profile) -}} + {{- $source = "/data/media/404.png" -}} + {{- $sourceset = "" -}} +{{- end -}} + +{{- with $sourceset -}} +<source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" /> +{{- end -}} <img - loading="lazy" - {{- with .Params.feed }} - width="64" - height="64" - alt="{{ .name }}" - src="{{ .image }}" - {{ else }} - {{ if fileExists $path }} - {{- with $image -}} - {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .))).Fit $dimensions -}} - width="{{ $image.Width }}" - height="{{ $image.Height }}" - src="{{ $image.RelPermalink }}" - {{ else -}} - src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}" - {{ end }} - {{- else -}} - width="{{ $404image.Width }}" - height="{{ $404image.Height }}" - src="{{ $404image.RelPermalink }}" - {{- end }} - alt="{{ partial "author-name.html" . }}" - {{ end -}} + width="{{ $width }}" + height="{{ $height }}" + src="{{ print ("" | absURL) $source }}" + alt="{{ $alternate }}" /> {{- /* This comment removes trailing newlines and white spaces. */ -}} |