{% from "macros/question.html" import render_question %}
{% macro render_topic(item, alternative) %}
{% set b_alt = 'topics' %}
{% set t = bag(b_alt, item._id) %}
<div class="item">
  <h3 class="text-primary">
    <a href="{{ t.path }}" role="button"></a>
  </h3>
  <div id="{{ t.control }}" role="tabpanel" data-parent="#topics" class="anchor-spacer">
    <div id="{{ t.control }}Accordion" data-children=".question">
      <h5 class="text-muted mb-3 p-0 {{ bag('alternatives', alternative, 'direction') }}">{{ item.title }}</h5>
      {% for q in item.children.include_undiscoverable(true).order_by('key') %}
        {% if q._model == 'redirect' %}
          {% set r = site.get(q.target, alt=alternative) %}
          {{ render_question(r, q._id, item._id, alternative) }}
        {% else %}
          {{ render_question(q, q._id, item._id, alternative) }}
        {% endif %}
      {% endfor %}
    </div>
  </div>
</div>
{% endmacro %}
