{{ 'collection_page.recent' | t }}

{% if collection != blank %} {% for product in collection.products limit: 4 %} {% assign card_suffix = section.id | append: '-recent-' | append: forloop.index %} {% render 'collection-card', product: product, form_suffix: card_suffix, badge_mode: 'collection' %} {% endfor %} {% endif %}
{% javascript %} (() => { if (window.__seasonRecent) return; window.__seasonRecent = true; const storageKey = 'seasons-recent'; const boot = async (root) => { if (!root || root.dataset.ready === 'true') return; root.dataset.ready = 'true'; let handles = []; try { const stored = JSON.parse(window.localStorage.getItem(storageKey)); if (Array.isArray(stored)) handles = stored.map(String).filter(Boolean); } catch (error) { handles = []; } handles = handles.slice(0, 4); const list = root.querySelector('[data-recent-list]'); if (!list) return; if (handles.length) { const prefix = `${root.dataset.root || '/'}`.replace(/\/?$/, '/'); const cards = await Promise.all(handles.map(async (handle) => { try { const response = await fetch(`${prefix}products/${encodeURIComponent(handle)}?view=card`, { headers: { Accept: 'text/html' } }); if (!response.ok) return null; const holder = document.createElement('div'); holder.innerHTML = (await response.text()).trim(); return holder.querySelector('.collection-card'); } catch (error) { return null; } })); const ready = cards.filter(Boolean); if (ready.length) list.replaceChildren(...ready); } root.hidden = list.children.length === 0; }; document.querySelectorAll('[data-recent]').forEach(boot); })(); {% endjavascript %} {% schema %} { "name": "t:collection_page.recent_name", "tag": "section", "class": "recent-section", "settings": [] } {% endschema %}