refactor(sidebar): improve creation of social links
This commit is contained in:
parent
af8986bf50
commit
5cbaf24bcb
1 changed files with 20 additions and 17 deletions
|
@ -64,34 +64,37 @@
|
|||
{% endunless %}
|
||||
|
||||
{% for entry in site.data.contact %}
|
||||
{% capture url %}
|
||||
{%- if entry.type == 'github' -%}
|
||||
https://github.com/{{ site.github.username }}
|
||||
{%- elsif entry.type == 'twitter' -%}
|
||||
https://twitter.com/{{ site.twitter.username }}
|
||||
{%- elsif entry.type == 'email' -%}
|
||||
{% case entry.type %}
|
||||
{% when 'github', 'twitter' %}
|
||||
{%- capture url -%}
|
||||
https://{{ entry.type }}.com/{{ site[entry.type].username }}
|
||||
{%- endcapture -%}
|
||||
{% when 'email' %}
|
||||
{% assign email = site.social.email | split: '@' %}
|
||||
{%- capture url -%}
|
||||
javascript:location.href = 'mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@')
|
||||
{%- elsif entry.type == 'rss' -%}
|
||||
{{ "/feed.xml" | relative_url }}
|
||||
{%- else -%}
|
||||
{{ entry.url }}
|
||||
{%- endif -%}
|
||||
{% endcapture %}
|
||||
{%- endcapture -%}
|
||||
{% when 'rss' %}
|
||||
{% assign url = '/feed.xml' | relative_url %}
|
||||
{% else %}
|
||||
{% assign url = entry.url %}
|
||||
{% endcase %}
|
||||
|
||||
{% if url %}
|
||||
<a href="{{ url }}" aria-label="{{ entry.type }}"
|
||||
{% assign link_types = nil %}
|
||||
{% assign link_types = '' %}
|
||||
|
||||
{% unless entry.noblank %}
|
||||
{% assign link_types = link_types | append: " noopener" %}
|
||||
target="_blank"
|
||||
{% assign link_types = 'noopener noreferrer' %}
|
||||
{% endunless %}
|
||||
|
||||
{% if entry.type == 'mastodon' %}
|
||||
{% assign link_types = link_types | append: " me" %}
|
||||
{% assign link_types = link_types | append: ' me' | strip %}
|
||||
{% endif %}
|
||||
|
||||
{% if link_types %}rel="{{ link_types | lstrip }}"{% endif %}>
|
||||
{% unless link_types == empty %}rel="{{ link_types }}"{% endunless %}>
|
||||
|
||||
<i class="{{ entry.icon }}"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue