---
import ArticleDetailView from "../../components/ArticleDetailView.astro";
import NotFoundPage from "../../components/NotFoundPage.astro";
import { getPublishedArticle, safeSlug } from "../../lib/article-store";

export const prerender = false;

const slug = safeSlug(Astro.params.slug);
const entry = slug ? await getPublishedArticle(slug) : null;
if (!entry) Astro.response.status = 404;
else Astro.response.headers.set("Cache-Control", "public, max-age=0, must-revalidate");
---
{entry ? <ArticleDetailView {entry} /> : <NotFoundPage />}
