{% macro render_tag(tag, counter, kind='tag') -%}
{# A tag or a category can be pass as argument as they share the same data structure #}
{% set kind = 'tag' if kind == 'tag' else 'category' %}
{{ 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-fill') %}{% endif %}
{% elif protocol.startswith('http') %}
{% set domain = link.split('%s://' % protocol, 1)[1].split('/', 1)[0] %}
{% set SITE_ICONS = {
"apple": [
"apple.com"
],
"dropbox": [
"dropbox.com"
],
"facebook": [
"facebook.com"
],
"github": [
"github.com"
],
"linkedin": [
"linkedin.com"
],
"stack-overflow": [
"stackexchange.com",
"stackoverflow.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 %}