hacks-guide-minimal-mistake.../_includes/gallery

50 lines
No EOL
1.4 KiB
Text

{% include base_path %}
{% if include.id %}
{% assign gallery = page.[include.id] %}
{% else %}
{% assign gallery = page.gallery %}
{% endif %}
{% capture gallery-size %}{{ gallery | size }}{% endcapture %}
{% if gallery-size == '2' %}
{% assign gallery-layout = 'half' %}
{% elsif gallery-size >= '3' %}
{% assign gallery-layout = 'third' %}
{% else %}
{% assign gallery-layout = '' %}
{% endif %}
<figure class="{{ gallery-layout }} {{ include.class }}">
{% for img in gallery %}
{% if img.url %}
<a href=
{% if img.url contains "http" %}
"{{ img.url }}"
{% else %}
"{{ img.url | prepend: "/images/" | prepend: base_path }}"
{% endif %}
>
<img src=
{% if img.image_path contains "http" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | prepend: "/images/" | prepend: base_path }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
</a>
{% else %}
<img src=
{% if img.image_path contains "http" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | prepend: "/images/" | prepend: base_path }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
{% endif %}
{% endfor %}
{% if include.caption %}
<figcaption>{{ include.caption | markdownify | remove: "<p>" | remove: "</p>" }}</figcaption>
{% endif %}
</figure>