{# :t posts = list[typedef.AbbreviatedPost]
   :t highlightFavourites = bool
   :t splitYears = bool #}
{% macro postList(posts, highlightFavourites=True, splitYears=True) -%}
    {% if splitYears %}
        {% for year, items in posts|groupby("publishedDate.year")|reverse %}
            <h2 id="year-{{ year }}">{{ year }}</h2>
            <ul>
                {% for post in items %}
                    {{ postListItem(post, highlightFavourites) }}
                {% endfor %}
            </ul>
        {% endfor %}
    {% else %}
        <ul>
            {% for post in posts %}
                {{ postListItem(post, highlightFavourites) }}
            {% endfor %}
        </ul>
    {% endif %}
{%- endmacro %}

{% macro postListItem(post, highlightFavourite) -%}
{% set showFavourite = post.isFavourite and highlightFavourite %}
<li>
    <span class="font--tnum text--secondary">{{ post.publishedDate | fmtdate }}</span> {% if showFavourite %}<b class="favourite">{% endif %}<a href="/blog/{{ post.slug }}">{{ post.title }}</a>{% if showFavourite %}</b>{% endif %}
</li>
{%- endmacro %}

{% macro feedHeaders() -%}
<link rel="alternate" type="application/atom+xml" href="/blog/feed.atom">
<link rel="alternate" type="application/json" href="/blog/feed.json">
{% endmacro %}