// Grab ?id=XXX const params=new URLSearchParams(window.location.search); const id=params.get('id'); const container=document.getElementById('project'); if(!id){ container.textContent='No project id 🙃'; throw new Error('Missing id param'); } fetch('projects/projects.json') .then(r=>r.json()) .then(list=>{ const proj=list.find(p=>p.id===id); if(!proj) throw new Error('Unknown project'); container.innerHTML=`

${proj.title}

`; // Pull in optional text files ['info','credits'].forEach(key=>{ if(!proj[key]) return; fetch(proj[key]) .then(r=>r.text()) .then(txt=>{ document.getElementById(key).innerHTML= `

${key}

${txt.replace(/\n/g,'
')}

`; }); }); }) .catch(err=>{ console.error(err); container.innerHTML='

Project not found.

'; });