diff --git a/themes/intotheeast/templates/home.html.twig b/themes/intotheeast/templates/home.html.twig new file mode 100644 index 0000000..8c05381 --- /dev/null +++ b/themes/intotheeast/templates/home.html.twig @@ -0,0 +1,168 @@ +{% extends 'partials/base.html.twig' %} + +{% block content %} +{% set slug = config.site.active_trip %} +{% set trip = grav.pages.find('/trips/' ~ slug) %} +{% set dailies_page = grav.pages.find('/trips/' ~ slug ~ '/dailies') %} +{% set stories_page = grav.pages.find('/trips/' ~ slug ~ '/stories') %} +{% set journal_entries = dailies_page ? dailies_page.children.published() : [] %} +{% set story_entries = stories_page ? stories_page.children.published() : [] %} + +{% set all_items = [] %} +{% for e in journal_entries %} + {% set all_items = all_items|merge([{'type': 'journal', 'page': e, 'date': e.date}]) %} +{% endfor %} +{% for s in story_entries %} + {% set all_items = all_items|merge([{'type': 'story', 'page': s, 'date': s.date}]) %} +{% endfor %} +{% set all_items = all_items|sort((a, b) => a.date < b.date ? 1 : -1) %} + +{% set journal_count = journal_entries|length %} +{% set story_count = story_entries|length %} + +{% set map_entries = [] %} +{% for item in all_items %} + {% if item.type == 'journal' and item.page.header.lat is not empty and item.page.header.lng is not empty %} + {% set map_entries = map_entries|merge([{ + 'lat': item.page.header.lat|number_format(6, '.', ''), + 'lng': item.page.header.lng|number_format(6, '.', ''), + 'slug': item.page.slug, + 'title': item.page.title + }]) %} + {% endif %} +{% endfor %} + +
+
+
+
+ +
+
+

{{ trip ? trip.title : slug }}

+ + {{ journal_count }} journal {{ journal_count == 1 ? 'entry' : 'entries' }} + {% if story_count > 0 %} · {{ story_count }} {{ story_count == 1 ? 'story' : 'stories' }}{% endif %} + +
+ +
+ {% if all_items|length > 0 %} + {% for item in all_items %} + {% set entry = item.page %} + {% set hero = null %} + {% if entry.header.hero_image and entry.media[entry.header.hero_image] is defined %} + {% set hero = entry.media[entry.header.hero_image] %} + {% elseif entry.media.images|length > 0 %} + {% set hero = entry.media.images|first %} + {% endif %} + + {% if item.type == 'journal' %} +
+ + {% if hero %} +
+ {{ entry.title }} +
+ + {% if entry.header.location_city or entry.header.location_country %} + + 📍 + {% if entry.header.location_city %}{{ entry.header.location_city|slice(0,20) }}{% endif %} + {% if entry.header.location_city and entry.header.location_country %}, {% endif %} + {% if entry.header.location_country %}{{ entry.header.location_country }}{% endif %} + + {% endif %} +
+
+ {% else %} +
+ + {% if entry.header.location_city or entry.header.location_country %} + + {%- set _loc = [] -%} + {%- if entry.header.location_city -%}{%- set _loc = _loc|merge([entry.header.location_city]) -%}{%- endif -%} + {%- if entry.header.location_country -%}{%- set _loc = _loc|merge([entry.header.location_country]) -%}{%- endif -%} + 📍 {{ _loc|join(', ') }} + + {% endif %} +
+ {% endif %} +
+

{{ entry.title }}

+

{{ entry.summary|striptags|slice(0, 250)|trim }}

+ Read entry → +
+
+
+ {% else %} + + {% endif %} + {% endfor %} + {% else %} +

No entries yet. The journey is about to begin.

+ {% endif %} +
+
+
+ +{% if map_entries|length > 0 %} + + + +{% endif %} +{% endblock %}