mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-28 19:43:31 +08:00
feat(sidebar): add support for external avatar
- 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
This commit is contained in:
parent
a70b1cb38b
commit
b3680cd7ef
@ -21,8 +21,10 @@ DefaultContentLanguage = "en" # Theme i18n support
|
||||
|
||||
[params.sidebar]
|
||||
emoji = "🍥"
|
||||
avatar = "img/avatar.png"
|
||||
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||
[params.sidebar.avatar]
|
||||
local = true
|
||||
src = "img/avatar.png"
|
||||
|
||||
[params.article]
|
||||
math = false
|
||||
|
@ -8,10 +8,10 @@
|
||||
<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">
|
||||
{{ if not .local }}
|
||||
<img src="{{ .src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
|
||||
{{ else }}
|
||||
{{$avatar := resources.Get (.) }}
|
||||
{{ $avatar := resources.Get (.src) }}
|
||||
|
||||
{{ if $avatar }}
|
||||
{{ $avatarResized := $avatar.Resize "300x" }}
|
||||
|
Loading…
Reference in New Issue
Block a user