---
import { getCollection, getEntry } from 'astro:content';
import AppLayout from '../../layouts/AppLayout.astro';
import { fmtDate } from '../../lib/markdown';
const user = Astro.locals.user;
const { slug } = Astro.params;
const update = await getEntry('updates', slug as string);
if (!update) return Astro.redirect('/updates');
const { Content } = await update.render();
const allUpdates = await getCollection('updates');
const sorted = allUpdates.sort(
(a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime()
);
const currentIndex = sorted.findIndex((u) => u.slug === update.slug);
const prev = sorted[currentIndex + 1] ?? null;
const next = sorted[currentIndex - 1] ?? null;
---
{update.data.title}
{update.data.summary}
{update.data.author}