webapp/src/pages/index.astro
2022-11-15 17:24:50 +03:00

22 lines
705 B
Plaintext

---
import Prerendered from '../main.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.loadShoutsBy(
{ by: { visibility: "public" }, amount: PRERENDERED_ARTICLES_COUNT, offset: 0 })
const { pathname, search } = Astro.url
initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
<Prerendered>
<Root randomTopics={randomTopics} shouts={articles} client:load />
</Prerendered>