Add gravatar as a separate social param

Make gravatar and authorimage mutually exclusive
This commit is contained in:
Taras Matsyk 2018-11-23 22:22:36 +02:00
parent 6b1f227642
commit a02e3640c9
No known key found for this signature in database
GPG key ID: 8DD284C92A23F12E

View file

@ -5,14 +5,16 @@
<span class="site__title"> <span class="site__title">
<a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a> <a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
</span> </span>
{{ with .Site.Params.authorimage }} {{ if and (isset .Site.Params "authorimage") (not (isset .Site.Params.social "gravatar")) }}
{{ $strippedSlash := ($.Site.Params.authorimage | replaceRE "^(/)+(.*)" "$2") }} {{ with .Site.Params.authorimage }}
{{ $authorImage := (printf "%s/%s" $.Site.BaseURL $strippedSlash) }} {{ $strippedSlash := ($.Site.Params.authorimage | replaceRE "^(/)+(.*)" "$2") }}
<div class="author-image"> {{ $authorImage := (printf "%s/%s" $.Site.BaseURL $strippedSlash) }}
<img src="{{$authorImage}}" alt="Author Image" class="img--circle img--headshot element--center"> <div class="author-image">
</div> <img src="{{$authorImage}}" alt="Author Image" class="img--circle img--headshot element--center">
</div>
{{ end }}
{{ end }} {{ end }}
{{ with .Site.Params.social.email}} {{ with .Site.Params.social.gravatar}}
<div class="author-image"> <div class="author-image">
<img src="https://www.gravatar.com/avatar/{{md5 .}}?s=240&d=mp" class="img--circle img--headshot element--center" alt="gravatar"> <img src="https://www.gravatar.com/avatar/{{md5 .}}?s=240&d=mp" class="img--circle img--headshot element--center" alt="gravatar">
</div> </div>