{% extends "base.html" %}

{% block content %}
	<section class="wrap narrow centering">
		<h1>Galerie</h1>
		{{ section.content | safe }}
	</section>
	<section class="gallery-list wrap grid grid-4 grid-mobile-2">
		{% for gallery in section.pages %}
			<a href="{{ gallery.permalink }}">
				{% if gallery.extra.thumbnail %}
					{% set_global img = "." ~ gallery.path ~ gallery.extra.thumbnail %}
				{% else %}
					{% set_global img = "/static/img/placeholder.jpg" %}
					{% for asset in gallery.assets %}
						{% if asset is matching("[.](jpg|png)$") %}
							{% set_global img = asset %}
							{% break %}
						{% endif %}
					{% endfor %}
				{% endif %}
				{% set image = resize_image(path=img, width=300, height=200, op="fill") %}
				<img src="{{ image.url }}" alt="{{ gallery.title }}">
				<div>
					<span class="title">{{ gallery.title }}</span>
					<span class="year">{{ gallery.date | date(format="%Y") }}
				</div>
			</a>
		{% endfor %}
	</section>
{% endblock %}