mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
sidebar: allow loading external image resource (fix #50)
This commit is contained in:
parent
cd408279e4
commit
69df83528f
@ -8,15 +8,19 @@
|
||||
<header class="site-info">
|
||||
{{ with .Site.Params.sidebar.avatar }}
|
||||
<figure class="site-avatar">
|
||||
{{ if in (.) "http" }}
|
||||
<img src="{{ . }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
|
||||
{{ else }}
|
||||
{{$avatar := resources.Get (.) }}
|
||||
|
||||
{{ if $avatar }}
|
||||
{{ $avatarResized := $avatar.Resize "300x300" }}
|
||||
{{ $avatarResized := $avatar.Resize "300x" }}
|
||||
<img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
|
||||
height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
|
||||
{{ else }}
|
||||
{{ errorf "Failed loading avatar from %q" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<span class="emoji">{{ $.Site.Params.sidebar.emoji }}</span>
|
||||
</figure>
|
||||
|
Loading…
Reference in New Issue
Block a user