{% macro render_tag(tag) -%}
{{ tag.name }}
{%- endmacro %}
{% macro render_link_icon(link, label, favicon=True) -%}
{% set icon = [] %}
{% set favicon = False if favicon == False else True %}
{% set protocol = link.split(':', 1)[0] %}
{% if protocol == 'mailto' %}
{% if icon.append('envelope') %}{% endif %}
{% elif protocol.startswith('http') %}
{% set domain = link.split('%s://' % protocol, 1)[1].split('/', 1)[0] %}
{% set SITE_ICONS = {
'apple': ['apple.com']
, 'bitbucket': ['bitbucket.org', 'bitbucket.com']
, 'dropbox': ['dropbox.com']
, 'facebook-square': ['facebook.com']
, 'github': ['github.com']
, 'hacker-news': ['news.ycombinator.com']
, 'linkedin': ['linkedin.com']
, 'stack-overflow': ['stackoverflow.com']
, 'stack-exchange': ['stackexchange.com']
, 'twitter': ['twitter.com']
, 'youtube': ['youtube.com']
}
%}
{% for (site_icon, site_domains) in SITE_ICONS.items() %}
{% for site_domain in site_domains %}
{% if domain.startswith(site_domain) %}
{% if icon.append(site_icon) %}{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% if icon %}
{% elif domain and favicon %}
{% else %}
{% endif %}
{{ label }}
{%- endmacro %}