feat(sidebar): add support for external avatar (#53)
add [params.sidebar.avatar] section in config.toml, with 2 fields: local and src Migration guide: - Copy the old value of `params.sidebar.avatar` to `param.sidebar.avatar.src` - Set params.sidebar.avatar.local = true Co-authored-by: Jimmy Cai <jimmehcai@gmail.com>
This commit is contained in:
parent
bfeddf3217
commit
f919b8bd90
@ -21,8 +21,10 @@ DefaultContentLanguage = "en" # Theme i18n support
|
|||||||
|
|
||||||
[params.sidebar]
|
[params.sidebar]
|
||||||
emoji = "🍥"
|
emoji = "🍥"
|
||||||
avatar = "img/avatar.png"
|
|
||||||
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||||
|
[params.sidebar.avatar]
|
||||||
|
local = true
|
||||||
|
src = "img/avatar.png"
|
||||||
|
|
||||||
[params.article]
|
[params.article]
|
||||||
math = false
|
math = false
|
||||||
|
@ -8,14 +8,18 @@
|
|||||||
<header class="site-info">
|
<header class="site-info">
|
||||||
{{ with .Site.Params.sidebar.avatar }}
|
{{ with .Site.Params.sidebar.avatar }}
|
||||||
<figure class="site-avatar">
|
<figure class="site-avatar">
|
||||||
{{ $avatar := resources.Get (.) }}
|
{{ if not .local }}
|
||||||
|
<img src="{{ .src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
|
||||||
{{ if $avatar }}
|
|
||||||
{{ $avatarResized := $avatar.Resize "300x300" }}
|
|
||||||
<img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
|
|
||||||
height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "Failed loading avatar from %q" . }}
|
{{ $avatar := resources.Get (.src) }}
|
||||||
|
|
||||||
|
{{ if $avatar }}
|
||||||
|
{{ $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 }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with $.Site.Params.sidebar.emoji }}
|
{{ with $.Site.Params.sidebar.emoji }}
|
||||||
|
Loading…
Reference in New Issue
Block a user