From 933652fd57cf45094686ac44fd16c1e43ff56891 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sun, 21 Jun 2026 21:07:12 +0200 Subject: [PATCH] refactor(templates): extract entry markup into shared partials Creates partials/entry-journal.html.twig and partials/entry-story.html.twig so trip, dailies, and home all use the same up-to-date markup. Home page gains PhotoSwipe, blurred fill, adaptive aspect ratio, and hash-based marker scroll. Future changes only need to happen in one place. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr --- .../intotheeast/templates/dailies.html.twig | 79 +------------ themes/intotheeast/templates/home.html.twig | 106 +++++++----------- .../partials/entry-journal.html.twig | 59 ++++++++++ .../templates/partials/entry-story.html.twig | 17 +++ themes/intotheeast/templates/trip.html.twig | 79 +------------ 5 files changed, 120 insertions(+), 220 deletions(-) create mode 100644 themes/intotheeast/templates/partials/entry-journal.html.twig create mode 100644 themes/intotheeast/templates/partials/entry-story.html.twig diff --git a/themes/intotheeast/templates/dailies.html.twig b/themes/intotheeast/templates/dailies.html.twig index eaca391..3f4d007 100644 --- a/themes/intotheeast/templates/dailies.html.twig +++ b/themes/intotheeast/templates/dailies.html.twig @@ -91,85 +91,10 @@ feedMap.on('load', function () { {% if all_items|length > 0 %} {% for item in all_items %} {% set entry = item.page %} - {% if item.type == 'journal' %} - {% set weather_icons = { - 'Sunny': '☀️', 'Partly cloudy': '⛅', 'Cloudy': '☁️', - 'Foggy': '🌫️', 'Drizzle': '🌦️', 'Rain': '🌧️', - 'Snow': '❄️', 'Thunderstorm': '⛈️' - } %} -
-
-

{{ entry.title }}

- -
- - {% set images = entry.media.images %} - {% if images|length > 0 %} - {% set firstImg = images|first %} - {% set wrapRatio = firstImg.height > firstImg.width ? '4 / 5' : '4 / 3' %} -
- - {% if images|length > 1 %} - - {% endif %} - -
- {% endif %} - -
{{ entry.content|raw }}
-
+ {% include 'partials/entry-journal.html.twig' %} {% else %} - {% 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 hero %} -
- {{ entry.title }} -
- {% endif %} -
- ✦ Story -

{{ entry.title }}

-
-
+ {% include 'partials/entry-story.html.twig' %} {% endif %} {% endfor %} {% else %} diff --git a/themes/intotheeast/templates/home.html.twig b/themes/intotheeast/templates/home.html.twig index f24f343..9614745 100644 --- a/themes/intotheeast/templates/home.html.twig +++ b/themes/intotheeast/templates/home.html.twig @@ -1,6 +1,7 @@ {% extends 'partials/base.html.twig' %} {% block content %} + {% set trip_route = config.site.active_trip %} {% set trip = grav.pages.find(trip_route) %} @@ -65,73 +66,10 @@ {% if all_items|length > 0 %} {% for item in all_items %} {% set entry = item.page %} - {% if item.type == 'journal' %} - {% set weather_icons = { - 'Sunny': '☀️', 'Partly cloudy': '⛅', 'Cloudy': '☁️', - 'Foggy': '🌫️', 'Drizzle': '🌦️', 'Rain': '🌧️', - 'Snow': '❄️', 'Thunderstorm': '⛈️' - } %} -
-
-

{{ entry.title }}

- -
- - {% set images = entry.media.images %} - {% if images|length > 0 %} -
- {% for img in images %} -
- {{ entry.title }} -
- {% endfor %} -
- {% if images|length > 1 %} - - {% endif %} - {% endif %} - -
{{ entry.content|raw }}
-
+ {% include 'partials/entry-journal.html.twig' %} {% else %} - {% 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 hero %} -
- {{ entry.title }} -
- {% endif %} -
- ✦ Story -

{{ entry.title }}

-
-
+ {% include 'partials/entry-story.html.twig' %} {% endif %} {% endfor %} {% else %} @@ -180,7 +118,8 @@ homeMap.on('load', function () { el.addEventListener('mouseleave', function () { popup.remove(); }); el.addEventListener('click', function () { var card = document.getElementById('entry-' + entry.slug); - if (card) card.scrollIntoView({ behavior: 'smooth', block: 'center' }); + if (!card) return; + window.location.hash = 'entry-' + entry.slug; }); new maplibregl.Marker({ element: el }).setLngLat(lngLat).addTo(homeMap); @@ -199,6 +138,41 @@ homeMap.on('load', function () { {% endif %} + + {% else %} {# ══════════════════════════════════════════════════════ BETWEEN-TRIPS MODE #} diff --git a/themes/intotheeast/templates/partials/entry-journal.html.twig b/themes/intotheeast/templates/partials/entry-journal.html.twig new file mode 100644 index 0000000..980766c --- /dev/null +++ b/themes/intotheeast/templates/partials/entry-journal.html.twig @@ -0,0 +1,59 @@ +{% set weather_icons = { + 'Sunny': '☀️', 'Partly cloudy': '⛅', 'Cloudy': '☁️', + 'Foggy': '🌫️', 'Drizzle': '🌦️', 'Rain': '🌧️', + 'Snow': '❄️', 'Thunderstorm': '⛈️' +} %} +
+
+

{{ entry.title }}

+ +
+ + {% set images = entry.media.images %} + {% if images|length > 0 %} + {% set firstImg = images|first %} + {% set wrapRatio = firstImg.height > firstImg.width ? '4 / 5' : '4 / 3' %} +
+ + {% if images|length > 1 %} + + {% endif %} + +
+ {% endif %} + +
{{ entry.content|raw }}
+
diff --git a/themes/intotheeast/templates/partials/entry-story.html.twig b/themes/intotheeast/templates/partials/entry-story.html.twig new file mode 100644 index 0000000..dee014f --- /dev/null +++ b/themes/intotheeast/templates/partials/entry-story.html.twig @@ -0,0 +1,17 @@ +{% 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 hero %} +
+ {{ entry.title }} +
+ {% endif %} +
+ ✦ Story +

{{ entry.title }}

+
+
diff --git a/themes/intotheeast/templates/trip.html.twig b/themes/intotheeast/templates/trip.html.twig index 93d79a6..4f38710 100644 --- a/themes/intotheeast/templates/trip.html.twig +++ b/themes/intotheeast/templates/trip.html.twig @@ -216,85 +216,10 @@ {% if all_items|length > 0 %} {% for item in all_items %} {% set entry = item.page %} - {% if item.type == 'journal' %} - {% set weather_icons = { - 'Sunny': '☀️', 'Partly cloudy': '⛅', 'Cloudy': '☁️', - 'Foggy': '🌫️', 'Drizzle': '🌦️', 'Rain': '🌧️', - 'Snow': '❄️', 'Thunderstorm': '⛈️' - } %} -
-
-

{{ entry.title }}

- -
- - {% set images = entry.media.images %} - {% if images|length > 0 %} - {% set firstImg = images|first %} - {% set wrapRatio = firstImg.height > firstImg.width ? '4 / 5' : '4 / 3' %} -
- - {% if images|length > 1 %} - - {% endif %} - -
- {% endif %} - -
{{ entry.content|raw }}
-
+ {% include 'partials/entry-journal.html.twig' %} {% else %} - {% 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 hero %} -
- {{ entry.title }} -
- {% endif %} -
- ✦ Story -

{{ entry.title }}

-
-
+ {% include 'partials/entry-story.html.twig' %} {% endif %} {% endfor %} {% else %}