Skip to content

Commit 74a0fa4

Browse files
committed
Fix shared tour dates snippet: handle render_home and render_page modes
The snippet was checking `mode == 'render'` but both section files were calling it with mode: 'render_home' and mode: 'render_page', so no rows ever rendered. Now handles all three calling conventions: - render_home → gk-date-row prefix (home section CSS), no is-hidden - render_page → gk-date prefix, is-hidden on rows beyond visible_count - render → legacy explicit mode (row_prefix + use_hidden_class params) - count → returns upcoming date count only Also adds backward compatibility for gk-dates-page.liquid which uses the legacy mode: 'render' calling convention with explicit row_prefix param. To add/edit dates, update the _gk_dates_raw capture block in the snippet. Both sections update automatically. https://claude.ai/code/session_01GbgrA5NZvF9QCZUZdGUh1u
1 parent 44ccc46 commit 74a0fa4

File tree

1 file changed

+71
-36
lines changed

1 file changed

+71
-36
lines changed
Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,83 @@
11
{% comment %}
2-
GK Shared Tour Dates (Single Source of Truth)
3-
- Snippet ONLY (no schema allowed)
4-
- Renders rows for either:
5-
row_prefix: 'gk-date' (dates page styles)
6-
row_prefix: 'gk-date-row' (home styles)
7-
- Safe date filtering:
8-
show_ts == 0 => keep it (prevents blank if date parse fails)
2+
GK Shared Tour Dates — single source of truth
3+
Snippets cannot contain {% schema %}.
4+
5+
Calling conventions supported:
6+
7+
render 'gk-tour-dates-shared', mode: 'render_home'
8+
→ outputs .gk-date-row markup (home section CSS)
9+
→ all rows output; JS hides beyond initial_visible via style.display
10+
11+
render 'gk-tour-dates-shared', mode: 'render_page', visible_count: <n>
12+
→ outputs .gk-date markup
13+
→ rows beyond visible_count get class "is-hidden" (CSS hides, JS manages)
14+
15+
render 'gk-tour-dates-shared', mode: 'render', row_prefix: 'gk-date', visible_count: <n>, use_hidden_class: true
16+
→ legacy explicit mode (same output as render_page when row_prefix='gk-date')
17+
18+
render 'gk-tour-dates-shared', mode: 'count'
19+
→ outputs only the integer count of upcoming dates
20+
21+
Safe date filter:
22+
show_ts == 0 → Liquid can't parse the date string → keep it visible
23+
show_ts > 0 → hide the row if show is before today midnight UTC
924
{% endcomment %}
1025

1126
{%- liquid
12-
assign today_ymd = 'now' | date: '%Y-%m-%d'
27+
assign today_ymd = 'now' | date: '%Y-%m-%d'
1328
assign today_midnight_ts = today_ymd | date: '%s' | plus: 0
1429

15-
assign mode = mode | default: 'render'
16-
assign row_prefix = row_prefix | default: 'gk-date'
30+
assign mode = mode | default: 'count'
1731
assign visible_count = visible_count | default: 10
18-
assign use_hidden_class = use_hidden_class | default: false
32+
33+
if mode == 'render_home'
34+
assign row_prefix = 'gk-date-row'
35+
assign apply_hidden = false
36+
elsif mode == 'render_page'
37+
assign row_prefix = 'gk-date'
38+
assign apply_hidden = true
39+
elsif mode == 'render'
40+
assign row_prefix = row_prefix | default: 'gk-date'
41+
assign apply_hidden = use_hidden_class | default: false
42+
else
43+
assign row_prefix = 'gk-date'
44+
assign apply_hidden = false
45+
endif
1946
-%}
2047

48+
{%- comment -%}
49+
╔══════════════════════════════════════════════════════════════════╗
50+
║ DATE LIST — edit here to update BOTH sections at once ║
51+
║ Format per line: ║
52+
║ Date || Venue || City, State || Ticket URL || sold_out ║
53+
║ • Leave Ticket URL blank → shows "TBA" ║
54+
║ • Set sold_out = true → shows "SOLD OUT" ║
55+
║ • Use parseable date format: "Month DD, YYYY" ║
56+
╚══════════════════════════════════════════════════════════════════╝
57+
{%- endcomment -%}
2158
{%- capture _gk_dates_raw -%}
2259
March 15, 2026 || The Gig Shack || Nashville, TN || https://tickets.com || false
2360
April 02, 2026 || Blues Hall || Chicago, IL || || false
2461
{%- endcapture -%}
2562

2663
{%- assign date_rows = _gk_dates_raw | newline_to_br | split: '<br />' -%}
2764

28-
{%- assign render_index = 0 -%}
65+
{%- assign render_index = 0 -%}
2966
{%- assign upcoming_count = 0 -%}
3067

3168
{%- for row in date_rows -%}
3269
{%- assign trimmed = row | strip -%}
3370
{%- if trimmed != blank -%}
3471

35-
{%- assign parts = trimmed | split: ' || ' -%}
72+
{%- assign parts = trimmed | split: ' || ' -%}
3673
{%- assign raw_date = parts[0] | default: '' | strip -%}
37-
{%- assign venue = parts[1] | default: '' | strip -%}
38-
{%- assign city = parts[2] | default: '' | strip -%}
39-
{%- assign url = parts[3] | default: '' | strip -%}
40-
{%- assign sold = parts[4] | default: 'false' | strip -%}
74+
{%- assign venue = parts[1] | default: '' | strip -%}
75+
{%- assign city = parts[2] | default: '' | strip -%}
76+
{%- assign url = parts[3] | default: '' | strip -%}
77+
{%- assign sold = parts[4] | default: 'false' | strip -%}
4178

4279
{%- liquid
43-
assign show_ts = raw_date | date: '%s' | plus: 0
44-
80+
assign show_ts = raw_date | date: '%s' | plus: 0
4581
assign is_upcoming = false
4682
if raw_date != blank
4783
if show_ts == 0
@@ -55,14 +91,15 @@ April 02, 2026 || Blues Hall || Chicago, IL || || false
5591
{%- if is_upcoming -%}
5692
{%- assign upcoming_count = upcoming_count | plus: 1 -%}
5793

58-
{%- if mode == 'render' -%}
59-
{%- assign hidden_class = '' -%}
60-
{%- if use_hidden_class and render_index >= visible_count -%}
61-
{%- assign hidden_class = ' is-hidden' -%}
94+
{%- if mode == 'render_home' or mode == 'render_page' or mode == 'render' -%}
95+
96+
{%- assign extra_class = '' -%}
97+
{%- if apply_hidden and render_index >= visible_count -%}
98+
{%- assign extra_class = ' is-hidden' -%}
6299
{%- endif -%}
63100

64101
<div
65-
class="{{ row_prefix }}{{ hidden_class }}"
102+
class="{{ row_prefix }}{{ extra_class }}"
66103
role="listitem"
67104
data-date-row
68105
data-index="{{ render_index }}"
@@ -85,19 +122,17 @@ April 02, 2026 || Blues Hall || Chicago, IL || || false
85122
{%- else -%}
86123
<span class="{{ row_prefix }}__soldout" aria-label="Sold out">SOLD OUT</span>
87124
{%- endif -%}
125+
{%- elsif url != blank -%}
126+
{%- if row_prefix == 'gk-date' -%}
127+
<a class="gk-date__pill gk-date__pill--accent" href="{{ url }}" target="_blank" rel="noopener">GET TICKETS</a>
128+
{%- else -%}
129+
<a class="{{ row_prefix }}__btn" href="{{ url }}" target="_blank" rel="noopener">GET TICKETS</a>
130+
{%- endif -%}
88131
{%- else -%}
89-
{%- if url != blank -%}
90-
{%- if row_prefix == 'gk-date' -%}
91-
<a class="gk-date__pill gk-date__pill--accent" href="{{ url }}" target="_blank" rel="noopener">GET TICKETS</a>
92-
{%- else -%}
93-
<a class="{{ row_prefix }}__btn" href="{{ url }}" target="_blank" rel="noopener">GET TICKETS</a>
94-
{%- endif -%}
132+
{%- if row_prefix == 'gk-date' -%}
133+
<span class="gk-date__pill gk-date__pill--muted" aria-label="Tickets unavailable">TBA</span>
95134
{%- else -%}
96-
{%- if row_prefix == 'gk-date' -%}
97-
<span class="gk-date__pill gk-date__pill--muted" aria-label="Tickets unavailable">TBA</span>
98-
{%- else -%}
99-
<span class="{{ row_prefix }}__soldout" aria-label="Tickets unavailable">TBA</span>
100-
{%- endif -%}
135+
<span class="{{ row_prefix }}__soldout" aria-label="Tickets unavailable">TBA</span>
101136
{%- endif -%}
102137
{%- endif -%}
103138
</div>
@@ -113,4 +148,4 @@ April 02, 2026 || Blues Hall || Chicago, IL || || false
113148

114149
{%- if mode == 'count' -%}
115150
{{ upcoming_count }}
116-
{%- endif -%}
151+
{%- endif -%}

0 commit comments

Comments
 (0)