---
import { ArticlePage } from '../components/Views/ArticlePage'
import Zine from '../layouts/zine.astro'
import { apiClient } from '../utils/apiClient'

const slug = Astro.params.slug as string

if (slug.includes('/') || slug.includes('.map')) {
  return Astro.redirect('/404')
}

const article = await apiClient.getArticle({ slug })
if (!article) {
  return Astro.redirect('/404')
}

Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---

<Zine>
  <ArticlePage slug={slug} article={article} client:idle />
</Zine>
