make texts into a tags

This commit is contained in:
Yisroel Baum 2026-04-15 21:48:32 +03:00
parent 7ee4bac3fa
commit 3689945cfe
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -5,7 +5,12 @@ document.addEventListener('DOMContentLoaded', () => {
async function loadTexts() {
const res = await fetch('/api/texts');
const texts = await res.json();
textsList.innerHTML = texts.map(text => '<li>' + text.name + '</li>').join('');
textsList.innerHTML = texts.map(text =>
'<li><a href=/admin/texts/'
+ text.id
+ '>'
+ text.name
+ '</a></li>').join('');
}
form.addEventListener('submit', async (e) => {
@ -18,7 +23,10 @@ document.addEventListener('DOMContentLoaded', () => {
if (res.ok) {
const text = await res.json();
const li = document.createElement('li');
li.textContent = text.name;
const a = document.createElement('a');
a.href = '/admin/texts/' + text.id;
a.textContent = text.name;
li.appendChild(a);
textsList.appendChild(li);
form.reset();
}