diff options
Diffstat (limited to 'publications.js')
| -rw-r--r-- | publications.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/publications.js b/publications.js index 98867f8..22a0b59 100644 --- a/publications.js +++ b/publications.js @@ -20,30 +20,34 @@ */ function escapeXml(str) { return String(str) - .replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); } async function renderPublications() { - const list = document.querySelector('#recent-publications ul'); + const list = document.querySelector("#recent-publications ul"); try { - const res = await fetch('/publications.json'); + const res = await fetch("/publications.json"); const posts = await res.json(); if (posts.length === 0) { - list.innerHTML = '<li>No publications yet.</li>'; + list.innerHTML = "<li>No publications yet.</li>"; return; } - list.innerHTML = posts.map(p => ` + list.innerHTML = posts + .map( + (p) => ` <li> <a href="${escapeXml(p.url)}">${escapeXml(p.title.trim())}</a> - ${p.date ? `<div>${escapeXml(new Date(p.date).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }))}</div>` : ''} + ${p.date ? `<div>${escapeXml(new Date(p.date).toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric" }))}</div>` : ""} </li> - `).join(''); + `, + ) + .join(""); } catch (err) { - console.error('Failed to load publications:', err); + console.error("Failed to load publications:", err); list.innerHTML = "<li>Couldn't load publications right now.</li>"; } } |
