webapp/src/pages/author/[slug]/index.astro
2022-09-14 14:27:10 +03:00

18 lines
659 B
Plaintext

---
import { AuthorPage } from '../../../components/Views/Author'
import Zine from '../../../layouts/zine.astro'
import { apiClient } from '../../../utils/apiClient'
const limit = parseInt(Astro.params?.limit as string, 10) || 50
const offset = parseInt(Astro.params?.offset as string, 10) || 0
const slug = Astro.params.slug.toString()
const articles = await apiClient.getArticlesForAuthors({ authorSlugs: [slug], offset, limit })
const author = articles[0].authors.find((a) => a.slug === slug)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
<Zine>
<AuthorPage authorArticles={articles} author={author} />
</Zine>