webapp/src/pages/topic/[slug].astro
2022-12-07 20:49:03 +01:00

22 lines
715 B
Plaintext

---
import { Root } from '../../components/Root'
import Prerendered from '../../main.astro'
import { apiClient } from '../../utils/apiClient'
import { PRERENDERED_ARTICLES_COUNT } from '../../components/Views/Topic'
const slug = Astro.params.slug?.toString() || ''
const shouts = await apiClient.getShouts({ filters: { topic: slug }, limit: PRERENDERED_ARTICLES_COUNT })
const topic = await apiClient.getTopic({ slug })
import { initRouter } from '../../stores/router'
const { pathname, search } = Astro.url
initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
<Prerendered>
<Root topicShouts={shouts} topic={topic} client:load />
</Prerendered>