Added support for local avatar

Now user can choose to use local avatar or gravatar
This commit is contained in:
Giuseppe Pignataro 2019-03-27 10:48:55 +01:00
parent 72a9061bd7
commit 2fa50697fd
4 changed files with 29 additions and 12 deletions

View file

@ -51,7 +51,8 @@ disqusShortname = "yourdiscussshortname"
yandex_verification = ""
pinterest_verification = ""
baidu_verification = ""
avatar = "/images/me/avatar.jpg" #comment it to use gravatar
socialShare = true
description = "" # site description
@ -60,7 +61,8 @@ disqusShortname = "yourdiscussshortname"
license= 'Released under <a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a>'
[params.gravatar]
email = ""
#email = "example@gmail.com" #uncomment and insert your email address to use gravatar
[params.social]
GitHub = "xxxx"

View file

@ -109,3 +109,4 @@
</div>
</article>
{{- end }}

View file

@ -1,11 +1,20 @@
<div class="post-warp">
<div class="intro">
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ with .Site.Params.avatar}}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ $avatar := .}}
<div class="avatar">
<a href="/posts/"> <img src="{{ (printf "%s%s" $cdn_url $avatar)}}"> </a>
</div>
{{ end }}
{{ if or .Params.gravatar.Email (and .Site.Params.gravatar.Email (ne .Params.gravatar.Email false)) }}
<div class="avatar">
<a href="/posts/"> <img src="https://www.gravatar.com/avatar/{{ md5 .Site.Params.gravatar.email }}?s=240&d=mp" alt="gravatar"> </a>
</div>
</div>
{{ end }}
{{ with .Site.Params.subtitle}}
<h2 class="description">
{{ . }}
@ -60,6 +69,4 @@
{{ end }}
{{ partial "paginator.html" . }}
</div>
</div>

View file

@ -1,9 +1,16 @@
<div class="intro">
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<div class="avatar">
<a href="/posts/"> <img src="https://www.gravatar.com/avatar/{{ md5 .Site.Params.gravatar.email }}?s=240&d=mp" alt="gravatar"> </a>
{{ with .Site.Params.avatar}}
{{ $avatar := .}}
<div class="avatar">
<a href="/posts/"> <img src="{{ (printf "%s%s" $cdn_url $avatar)}}"> </a>
</div>
{{ end }}
{{ if or .Params.gravatar.Email (and .Site.Params.gravatar.Email (ne .Params.gravatar.Email false)) }}
<div class="avatar">
<a href="/posts/"> <img src="https://www.gravatar.com/avatar/{{ md5 .Site.Params.gravatar.email }}?s=240&d=mp" alt="gravatar"> </a>
</div>
{{ end }}
{{ with .Site.Params.subtitle}}
<h2 class="description">
{{ . }}
@ -11,6 +18,6 @@
{{ end }}
<div class="social-links">
{{ partial "social.html" . }}
</div>
</div>
</div>