Skip to content

Commit c5927f1

Browse files
committed
refactor(sidebar): adds condition for github/twitter username when displaying the icon as a contact
Ensures a GitHub or Twitter username is configured in `_config.yml` before displaying them in the sidebar. Adds a conditional to capture/assign `url` so that it is `nil` if no username was provided. That way when the check for `url` is done for building the link, it will be skipped if no username is configured.
1 parent eaf5e57 commit c5927f1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

_includes/sidebar.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@
5454
{% for entry in site.data.contact %}
5555
{% case entry.type %}
5656
{% when 'github', 'twitter' %}
57-
{%- capture url -%}
58-
https://{{ entry.type }}.com/{{ site[entry.type].username }}
59-
{%- endcapture -%}
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 %}
6064
{% when 'email' %}
6165
{% assign email = site.social.email | split: '@' %}
6266
{%- capture url -%}

0 commit comments

Comments
 (0)