From f596477d5fd9fbd733ac2f4dcdc96d00b209a8c8 Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Fri, 31 Jul 2026 10:44:22 +0200 Subject: [PATCH] fix broken dates --- themes/one-pager/assets/js/scripts.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/themes/one-pager/assets/js/scripts.js b/themes/one-pager/assets/js/scripts.js index 917d2b0..8c9d0a4 100644 --- a/themes/one-pager/assets/js/scripts.js +++ b/themes/one-pager/assets/js/scripts.js @@ -43,13 +43,14 @@ function buildPhotoArray() { currentPhotos = []; photoItems.forEach(item => { const image = item.querySelector('img'); + // FIX: Use dataset values directly const date = item.dataset.date || ''; const pubkey = item.dataset.pubkey || ''; const alt = item.dataset.alt || ''; if (image) { currentPhotos.push({ url: image.src, - alt: alt, + alt: alt || image.alt || '', date: date, pubkey: pubkey }); @@ -75,7 +76,13 @@ function openLightbox(index) { lightboxImage.src = photo.url; lightboxImage.alt = photo.alt; lightboxCaption.textContent = photo.alt; - lightboxMeta.textContent = `📅 ${photo.date}`; + + // FIX: Show date and pubkey in the meta + let metaText = ''; + if (photo.date) metaText += `📅 ${photo.date}`; + + lightboxMeta.textContent = metaText || '📅 No date available'; + lightboxCounter.textContent = `${currentIndex + 1} / ${currentPhotos.length}`; lightbox.classList.add('active'); @@ -253,6 +260,7 @@ function handleLyricsToggle() { // 4. PICTURES RENDERER // ============================================ +// Render random pictures (6 max) function renderRandomPictures(picturesData, containerId) { const container = document.getElementById(containerId); if (!container) return; @@ -282,10 +290,13 @@ function renderRandomPictures(picturesData, containerId) { item.dataset.image = imageUrl; item.dataset.alt = alt; + // FIX: Set the date in the dataset const date = new Date(picture.created_at * 1000); const dateStr = date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }); + item.dataset.date = dateStr; + item.dataset.pubkey = picture.pubkey || ''; item.innerHTML = ` ${imageUrl ? `${alt}` : ''}