2026-08-25 11:42:17 +02:00
|
|
|
import type { ArticleSummary, Paginated } from '#shared/types/blog'
|
|
|
|
|
|
|
|
|
|
export default defineEventHandler(async (event): Promise<Paginated<ArticleSummary>> => {
|
|
|
|
|
const query = getQuery(event)
|
|
|
|
|
const page = pageParam(query.page)
|
2026-09-08 23:34:42 +02:00
|
|
|
const locale = localeParam(query.lang)
|
2026-08-25 11:42:17 +02:00
|
|
|
const category = typeof query.category === 'string' ? query.category : null
|
|
|
|
|
|
|
|
|
|
const filter = category
|
|
|
|
|
? `&filters[category][slug][$eq]=${encodeURIComponent(category)}`
|
|
|
|
|
: ''
|
|
|
|
|
|
|
|
|
|
const response = await strapiFetch<StrapiList<ArticleSummary>>(
|
2026-09-08 23:34:42 +02:00
|
|
|
`/api/articles?${ARTICLE_SUMMARY_QUERY}&locale=${locale}&${pagination(page)}${filter}`
|
2026-08-25 11:42:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
items: response.data,
|
|
|
|
|
page: response.meta.pagination.page,
|
|
|
|
|
pageCount: response.meta.pagination.pageCount,
|
|
|
|
|
total: response.meta.pagination.total,
|
|
|
|
|
}
|
|
|
|
|
})
|