{% macro render_meta_description(entry) -%}
{# An explicit `Description:` metadata wins over the summary Pelican derives from the
body. Truncating before escaping keeps a cut from landing inside an entity. #}
{% if entry.description %}
{% elif entry.summary %}
{% endif %}
{%- endmacro %}
{% macro render_published_date(date, label) -%}
{# rather than : a date is not an abbreviation, and datetime is the
attribute a parser reads. title repeats the stamp to keep the hover tooltip the
this replaced used to give. -#}
{{ label }}
{%- endmacro %}
{% macro render_article_list(entries) -%}
{# The dated article list tag.html, category.html and period_archives.html each
render, over a collection of their own. #}
{% for article in entries %}
{{ render_published_date(article.date, article.locale_date) }}
{{ article.title }}
{% endfor %}
{%- endmacro %}
{% macro render_term_list(terms, badge_class) -%}
{# The taxonomy index authors.html and categories.html each render, differing only in
the badge color. Terms arrive as the {name, url, articles} dicts those templates build
from Pelican's (term, articles) pairs. #}
{# Sort by term frequency, then alphabetically #}
{% for term in terms|sort(attribute='name')|sort(reverse=True, attribute='articles') %}
{{ term.name }}
{{ term.articles }} article{{ 's' if term.articles > 1 else '' }}
{% endfor %}
{%- endmacro %}
{% 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) -%}
{# Bound up front rather than only in the http branch below. macros.html is imported
`with context`, so a name left unset in a branch that was not taken falls through to
the caller's globals instead of being undefined. #}
{% set domain = None %}
{% 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 %}