From 13d6576a2cbe14faad4f931586b93bbeea746226 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 20 Jun 2026 11:50:44 +0200 Subject: [PATCH] fix(story): smart date range formatting + blueprint end_date format fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blueprint: end_date format changed from 'Y-m-d H:i' to 'Y-m-d' — the demo frontmatter stores dates without a time component so Admin was failing to parse it and showing the field empty. Template: three-case smart range formatting: - Same month & year → 01 – 03 Sep 2025 - Same year only → 01 Jan – 03 Sep 2025 - Different years → 01 Jan 2025 – 03 Feb 2026 Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr --- themes/intotheeast/blueprints/story.yaml | 2 +- themes/intotheeast/templates/story.html.twig | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/themes/intotheeast/blueprints/story.yaml b/themes/intotheeast/blueprints/story.yaml index 770b86b..0d25825 100644 --- a/themes/intotheeast/blueprints/story.yaml +++ b/themes/intotheeast/blueprints/story.yaml @@ -27,7 +27,7 @@ form: header.end_date: type: datetime label: End Date - format: 'Y-m-d H:i' + format: 'Y-m-d' help: 'Optional — leave blank for a single-day story' header.hero_image: diff --git a/themes/intotheeast/templates/story.html.twig b/themes/intotheeast/templates/story.html.twig index 9ea650f..bba0b5c 100644 --- a/themes/intotheeast/templates/story.html.twig +++ b/themes/intotheeast/templates/story.html.twig @@ -13,7 +13,19 @@ {% set date_str = page.date|date('d M Y') %} {% if page.header.end_date %} - {% set date_str = page.date|date('d M Y') ~ ' – ' ~ page.header.end_date|date('d M Y') %} + {% set sd = page.date|date('d') %} + {% set sm = page.date|date('M') %} + {% set sy = page.date|date('Y') %} + {% set ed = page.header.end_date|date('d') %} + {% set em = page.header.end_date|date('M') %} + {% set ey = page.header.end_date|date('Y') %} + {% if sy == ey and sm == em %} + {% set date_str = sd ~ ' – ' ~ ed ~ ' ' ~ em ~ ' ' ~ ey %} + {% elseif sy == ey %} + {% set date_str = sd ~ ' ' ~ sm ~ ' – ' ~ ed ~ ' ' ~ em ~ ' ' ~ ey %} + {% else %} + {% set date_str = sd ~ ' ' ~ sm ~ ' ' ~ sy ~ ' – ' ~ ed ~ ' ' ~ em ~ ' ' ~ ey %} + {% endif %} {% endif %} {% set location = page.header.location_name ?? '' %}