{% extends "base.html" %}

{% block content %}
{%- set date_format = macros_translate::translate(key="date_format", default="%d %B %Y", language_strings=language_strings) -%}
{%- set date_locale = macros_translate::translate(key="date_locale", default="en_IE", language_strings=language_strings) -%}
<h1>{{ section.title }}</h1>

{{ section.description | markdown | safe }}

<small>
	<a href="{{ get_url(path='tags', lang=lang) }}">
		{{ macros_translate::translate(key="filter_by_tag", default="Filter by tag", language_strings=language_strings) }}
	</a>
	<br />
	{{ macros_translate::translate(key="newest_to_oldest", default="From newest to oldest", language_strings=language_strings) }} ↓
</small>

<div id="article-list">
	{%- for page in section.pages %}
		<article class="
			{% if page.draft %}draft{% endif %}
			{% if page.extra.archive %}archive{% endif %}
			{% if page.extra.featured %}featured{% endif %}">
			<h3><a href="{{ page.permalink | safe }}">{{ page.title }}</a></h3>
			{%- if page.draft %}
				<span class="draft-badge">
					<i class="icon"></i>
					{{ macros_translate::translate(key="drafted", default="Drafted", language_strings=language_strings) }}
				</span>
			{%- endif -%}
			{%- if page.extra.archive %}
				<span class="archive-badge">
					<i class="icon"></i>
					{{ macros_translate::translate(key="archived", default="Archived", language_strings=language_strings) }}
				</span>
			{%- endif %}
			{%- if page.extra.featured %}
				<span class="featured-badge">
					<i class="icon"></i>
					{{ macros_translate::translate(key="featured", default="Featured", language_strings=language_strings) }}
				</span>
			{%- endif %}
			{%- if page.description %}
				{{ page.description | markdown | safe }}
			{%- endif %}
			{%- if page.date %}
				<small>
					<time datetime="{{ page.date | date(format='%+') }}" pubdate>
						{{ page.date | date(format=date_format, locale=date_locale) }}
					</time>
					{%- if page.authors %}
						<span>•</span>
						<span>{{ macros_translate::translate(key="author", default="Author", language_strings=language_strings) }}: {{ page.authors[0] }}</span>
					{%- endif %}
					{%- if page.taxonomies %}
						{%- for name, taxon in page.taxonomies %}
							<ul class="tags inline">
								{%-for item in taxon %}
									<li><a class="tag" href="{{ get_taxonomy_url(kind=name, name=item, lang=lang) }}">{{ item }}</a></li>
								{%- endfor %}
							</ul>
						{%- endfor %}
					{%- endif %}
				</small>
			{%- endif %}
		</article>
		<hr>
	{%- endfor %}
</div>
{% endblock content %}
