{% extends "forum/_base.html" %}

{% from "macros/box.html" import m_box_menu, m_box_content %}

{% block content %}
  {% call m_box_content(_("Archives")) %}
    {% for month, threads in grouped_threads %}
      <h2>{{ month }}</h2>

      <ul class="threads-archives">
        {% for thread in threads %}
          {{ m_thread(thread) }}
        {% endfor %}
      </ul>
    {% else %}
      <p>{{ _("No message has been posted to this community yet") }}</p>
    {% endfor %}
  {% endcall %}
{% endblock %}


{% macro m_thread(thread) %}
  {%- set thread_href = url_for(".thread", thread_id=thread.id, community_id=g.community.slug) %}
  {%- set thread_length = thread.posts|length %}
  <li>
    <a href="{{ thread_href }}">{{ thread.title }}</a>
    {%- if thread_length > 1 %}
    <span class="comments">
      (<i class="fa fa-comments"></i> {{ thread_length-1 }})
    </span>

    {%- endif %}
  </li>
{% endmacro %}
