---
import Zine from '../layouts/zine.astro'
import { Root } from '../components/Root'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Home'

const randomTopics = await apiClient.getRandomTopics({ amount: 12 })
const articles = await apiClient.getRecentPublishedArticles({ limit: PRERENDERED_ARTICLES_COUNT })

const { pathname, search } = Astro.url
initRouter(pathname, search)

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

<Zine>
  <Root randomTopics={randomTopics} homeArticles={articles} client:load />
</Zine>

