Skip to content

Commit ba8c1b8

Browse files
authored
refactor: improve condition
Refactor contact entry URL generation logic to skip entries without usernames or emails. Signed-off-by: Cotes Chung <[email protected]>
1 parent c5927f1 commit ba8c1b8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

_includes/sidebar.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,21 @@
5252
{% endunless %}
5353

5454
{% for entry in site.data.contact %}
55+
{%- assign url = null -%}
56+
5557
{% case entry.type %}
5658
{% when 'github', 'twitter' %}
57-
{% if site[entry.type].username %}
58-
{%- capture url -%}
59-
https://{{ entry.type }}.com/{{ site[entry.type].username }}
60-
{%- endcapture -%}
61-
{% else %}
62-
{% assign url = nil %}
63-
{% endif %}
59+
{%- unless site[entry.type].username -%}
60+
{%- continue -%}
61+
{%- endunless -%}
62+
{%- capture url -%}
63+
https://{{ entry.type }}.com/{{ site[entry.type].username }}
64+
{%- endcapture -%}
6465
{% when 'email' %}
65-
{% assign email = site.social.email | split: '@' %}
66+
{%- unless site.social.email -%}
67+
{%- continue -%}
68+
{%- endunless -%}
69+
{%- assign email = site.social.email | split: '@' -%}
6670
{%- capture url -%}
6771
javascript:location.href = 'mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@')
6872
{%- endcapture -%}

0 commit comments

Comments
 (0)