document.addEventListener('DOMContentLoaded', () => { const textId = window.location.pathname.split('/').pop(); fetch('/api/texts/' + textId) .then(res => res.json()) .then(text => { document.getElementById('text-detail').textContent = text.name; }); });