Fix avatar url when site.baseurl exists (#253)

This commit is contained in:
Cotes Chung 2021-01-17 21:47:11 +08:00
parent ef1d05d342
commit 6490b0fcbd

View file

@ -10,17 +10,16 @@
<div class="profile-wrapper text-center"> <div class="profile-wrapper text-center">
<div id="avatar"> <div id="avatar">
<a href="{{ site.baseurl }}/" alt="avatar" class="mx-auto"> <a href="{{ '/' | relative_url }}" alt="avatar" class="mx-auto">
{% assign avatar_url = site.avatar %} {% capture avatar_url %}
{%- if site.avatar contains '://' -%}
{% unless avatar_url contains '://' %} {{ site.avatar }}
{% if site.img_cdn %} {%- elsif site.img_cdn != '' and site.img_cdn -%}
{% assign avatar_url = avatar_url | prepend: site.img_cdn %} {{ site.avatar | prepend: site.img_cdn }}
{% else %} {%- else -%}
{% assign avatar_url = avatar_url | relative_url %} {{ site.avatar | relative_url }}
{% endif %} {%- endif -%}
{% endunless %} {% endcapture %}
<img src="{{ avatar_url }}" alt="avatar" onerror="this.style.display='none'"> <img src="{{ avatar_url }}" alt="avatar" onerror="this.style.display='none'">
</a> </a>
</div> </div>