fix broken dates
This commit is contained in:
parent
842aeefa81
commit
f596477d5f
1 changed files with 13 additions and 2 deletions
|
|
@ -43,13 +43,14 @@ function buildPhotoArray() {
|
||||||
currentPhotos = [];
|
currentPhotos = [];
|
||||||
photoItems.forEach(item => {
|
photoItems.forEach(item => {
|
||||||
const image = item.querySelector('img');
|
const image = item.querySelector('img');
|
||||||
|
// FIX: Use dataset values directly
|
||||||
const date = item.dataset.date || '';
|
const date = item.dataset.date || '';
|
||||||
const pubkey = item.dataset.pubkey || '';
|
const pubkey = item.dataset.pubkey || '';
|
||||||
const alt = item.dataset.alt || '';
|
const alt = item.dataset.alt || '';
|
||||||
if (image) {
|
if (image) {
|
||||||
currentPhotos.push({
|
currentPhotos.push({
|
||||||
url: image.src,
|
url: image.src,
|
||||||
alt: alt,
|
alt: alt || image.alt || '',
|
||||||
date: date,
|
date: date,
|
||||||
pubkey: pubkey
|
pubkey: pubkey
|
||||||
});
|
});
|
||||||
|
|
@ -75,7 +76,13 @@ function openLightbox(index) {
|
||||||
lightboxImage.src = photo.url;
|
lightboxImage.src = photo.url;
|
||||||
lightboxImage.alt = photo.alt;
|
lightboxImage.alt = photo.alt;
|
||||||
lightboxCaption.textContent = 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}`;
|
lightboxCounter.textContent = `${currentIndex + 1} / ${currentPhotos.length}`;
|
||||||
|
|
||||||
lightbox.classList.add('active');
|
lightbox.classList.add('active');
|
||||||
|
|
@ -253,6 +260,7 @@ function handleLyricsToggle() {
|
||||||
// 4. PICTURES RENDERER
|
// 4. PICTURES RENDERER
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|
||||||
|
// Render random pictures (6 max)
|
||||||
function renderRandomPictures(picturesData, containerId) {
|
function renderRandomPictures(picturesData, containerId) {
|
||||||
const container = document.getElementById(containerId);
|
const container = document.getElementById(containerId);
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
@ -282,10 +290,13 @@ function renderRandomPictures(picturesData, containerId) {
|
||||||
item.dataset.image = imageUrl;
|
item.dataset.image = imageUrl;
|
||||||
item.dataset.alt = alt;
|
item.dataset.alt = alt;
|
||||||
|
|
||||||
|
// FIX: Set the date in the dataset
|
||||||
const date = new Date(picture.created_at * 1000);
|
const date = new Date(picture.created_at * 1000);
|
||||||
const dateStr = date.toLocaleDateString('en-US', {
|
const dateStr = date.toLocaleDateString('en-US', {
|
||||||
year: 'numeric', month: 'short', day: 'numeric'
|
year: 'numeric', month: 'short', day: 'numeric'
|
||||||
});
|
});
|
||||||
|
item.dataset.date = dateStr;
|
||||||
|
item.dataset.pubkey = picture.pubkey || '';
|
||||||
|
|
||||||
item.innerHTML = `
|
item.innerHTML = `
|
||||||
${imageUrl ? `<img src="${imageUrl}" alt="${alt}" loading="lazy">` : ''}
|
${imageUrl ? `<img src="${imageUrl}" alt="${alt}" loading="lazy">` : ''}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue