Add WikiLog page and nav link showing last 50 content changes

This commit is contained in:
Davide Scaini
2026-05-08 08:50:31 +02:00
parent 476f605a4a
commit dfce744001
2 changed files with 44 additions and 4 deletions
+37
View File
@@ -0,0 +1,37 @@
---
import Base from '../../layouts/Base.astro';
import { SITE_TITLE } from '../../consts';
---
<Base title={`WikiLog — ${SITE_TITLE}`} description="Ultime modifiche al wiki">
<div class="max-w-3xl mx-auto">
<h1 class="text-3xl font-bold mb-8" style="color: var(--text-primary)">WikiLog</h1>
<div id="log-list" class="space-y-2">
<p class="text-sm" style="color: var(--text-4)">Caricamento…</p>
</div>
</div>
</Base>
<script>
fetch('/api/log', { credentials: 'include' })
.then(r => r.json())
.then(({ log }) => {
const el = document.getElementById('log-list');
if (!el) return;
if (!log?.length) { el.innerHTML = '<p class="text-sm" style="color:var(--text-4)">Nessuna modifica ancora.</p>'; return; }
el.innerHTML = log.map((e: any) => {
const [author, rest] = e.message.includes(': ') ? e.message.split(': ', 2) : ['', e.message];
return `
<div class="flex items-baseline gap-3 px-3 py-2 rounded-lg text-sm" style="background:var(--bg-card)">
<span class="font-mono text-xs shrink-0" style="color:var(--text-5)">${e.hash}</span>
<span class="shrink-0" style="color:var(--accent)">${author || e.author}</span>
<span class="flex-1 truncate" style="color:var(--text-2)">${rest || e.message}</span>
<span class="shrink-0 text-xs" style="color:var(--text-5)">${e.date}</span>
</div>`;
}).join('');
})
.catch(() => {
const el = document.getElementById('log-list');
if (el) el.innerHTML = '<p class="text-sm" style="color:#f87171">Errore nel caricamento.</p>';
});
</script>