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 id="avatar">
<a href="{{ site.baseurl }}/" alt="avatar" class="mx-auto">
{% assign avatar_url = site.avatar %}
{% unless avatar_url contains '://' %}
{% if site.img_cdn %}
{% assign avatar_url = avatar_url | prepend: site.img_cdn %}
{% else %}
{% assign avatar_url = avatar_url | relative_url %}
{% endif %}
{% endunless %}
<a href="{{ '/' | relative_url }}" alt="avatar" class="mx-auto">
{% capture avatar_url %}
{%- if site.avatar contains '://' -%}
{{ site.avatar }}
{%- elsif site.img_cdn != '' and site.img_cdn -%}
{{ site.avatar | prepend: site.img_cdn }}
{%- else -%}
{{ site.avatar | relative_url }}
{%- endif -%}
{% endcapture %}
<img src="{{ avatar_url }}" alt="avatar" onerror="this.style.display='none'">
</a>
</div>