fix broken dates

This commit is contained in:
sakrecoer 2026-07-31 10:44:22 +02:00
parent 842aeefa81
commit f596477d5f

View file

@ -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 ? `<img src="${imageUrl}" alt="${alt}" loading="lazy">` : ''}