// Shared helpers for public pages. function fmtDate(iso) { if (!iso) return ""; const d = new Date(iso + "T00:00:00"); return d.toLocaleDateString(getLocale(), { month: "long", day: "numeric", year: "numeric" }); } function fmtRange(start, end) { if (!start || !end) return ""; const locale = getLocale(); const s = new Date(start + "T00:00:00"); const e = new Date(end + "T00:00:00"); const sMonth = s.toLocaleDateString(locale, { month: "long" }); const eMonth = e.toLocaleDateString(locale, { month: "long" }); const sameYear = s.getFullYear() === e.getFullYear(); if (sMonth === eMonth && sameYear) { return `${sMonth} ${s.getDate()} – ${e.getDate()}, ${e.getFullYear()}`; } if (sameYear) { return `${sMonth} ${s.getDate()} – ${eMonth} ${e.getDate()}, ${e.getFullYear()}`; } return `${sMonth} ${s.getDate()}, ${s.getFullYear()} – ${eMonth} ${e.getDate()}, ${e.getFullYear()}`; } function qs(key) { return new URLSearchParams(location.search).get(key); } function mount(id, html) { const el = document.getElementById(id); if (el) el.innerHTML = html; } const LOGO_SVG = ` `; function navHtml(active) { const items = [ ["index.html", t("nav.home"), "home"], ["artists.html", t("nav.artists"), "artists"], ["exhibitions.html", t("nav.exhibitions"), "exhibitions"], ["news.html", t("nav.news"), "news"], ["about.html", t("nav.about"), "about"], ["contact.html", t("nav.contact"), "contact"] ]; const s = Store.settings(); return ` `; } function footerHtml() { const s = Store.settings(); return ` `; } function renderChrome(active) { mount("nav-slot", navHtml(active)); mount("footer-slot", footerHtml()); wireLangSwitcher(); // Update document title if page key maps to a known title if (active) { const titleKey = "title." + active; const s = Store.settings(); document.title = `${t(titleKey)} — ${s.galleryName}`; } }