fix: mood TypeError crash + absolute fallback path in post.js

This commit is contained in:
jae 2026-04-06 20:29:14 +00:00
parent bb2aecd9b8
commit a40c91aa3f

View file

@ -119,7 +119,7 @@
const el = document.getElementById('postStats');
if (!el) return;
const moodStr = (post.mood || 'focused').toLowerCase();
const moodStr = String(post.mood || 'focused').toLowerCase();
const moodIcon = moodIcons[moodStr] || '◈';
const moodColor = moodColors[moodStr] || '#d0d0d0';
const hr = post.heart_rate || post.bpm || 72;
@ -319,7 +319,7 @@
} catch (err) {
// Fallback: try static JSON
try {
const res2 = await fetch('api/data/posts.json');
const res2 = await fetch('/api/data/posts.json');
const posts = await res2.json();
const post = posts.find(p => p.slug === slug);
if (!post) throw new Error('Not found');