refactor: drop support for external avatar

This simplifies the code and the configuration file
This commit is contained in:
Jimmy Cai 2023-09-11 18:40:53 +02:00
parent 692804498d
commit 22c7048f89
3 changed files with 7 additions and 24 deletions

View File

@ -29,10 +29,7 @@ sidebar:
emoji: emoji:
subtitle: subtitle:
compact: false compact: false
avatar: avatar: img/avatar.png
enabled: true
local: true
src: img/avatar.png
article: article:
# Enable LaTeX math syntax for all pages by default # Enable LaTeX math syntax for all pages by default

View File

@ -8,10 +8,7 @@ footer:
sidebar: sidebar:
emoji: 🍥 emoji: 🍥
subtitle: Lorem ipsum dolor sit amet, consectetur adipiscing elit. subtitle: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
avatar: avatar: img/logo.jpg
enabled: true
local: true
src: img/logo.jpg
comments: comments:
enabled: true enabled: true

View File

@ -7,28 +7,17 @@
<header> <header>
{{ with .Site.Params.sidebar.avatar }} {{ with .Site.Params.sidebar.avatar }}
{{ if .enabled }} {{- $avatar := resources.Get . -}}
{{- $avatarResized := $avatar.Resize "300x" -}}
{{- $src := $avatarResized.RelPermalink -}}
<figure class="site-avatar"> <figure class="site-avatar">
<a href="{{ .Site.BaseURL | relLangURL }}"> <a href="{{ $.Site.BaseURL | relLangURL }}">
{{ if not .local }} <img src="{{ $src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
<img src="{{ .src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
{{ else }}
{{ $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 }}
</a> </a>
{{ with $.Site.Params.sidebar.emoji }} {{ with $.Site.Params.sidebar.emoji }}
<span class="emoji">{{ . }}</span> <span class="emoji">{{ . }}</span>
{{ end }} {{ end }}
</figure> </figure>
{{ end }}
{{ end }} {{ end }}
<div class="site-meta"> <div class="site-meta">