feat: articles pagination
This commit is contained in:
1 parent
a2d224240c
commit
73f4b539fe
45 files changed
+3528
-317
No files matched your search
@@ -95,6 +95,25 @@ const FORMAT_QUERY: ApiField = {
|
||||
rule: 'markdown, html or json. Default markdown.',
|
||||
}
|
||||
|
||||
const ARTICLE_LIST_QUERY: ApiField[] = [
|
||||
FORMAT_QUERY,
|
||||
{ name: 'page', type: 'number', required: false, rule: 'A whole number from 1. Default 1.' },
|
||||
{ name: 'size', type: 'number', required: false, rule: '5, 25, 50 or 100. Default 25.' },
|
||||
{
|
||||
name: 'q',
|
||||
type: 'string',
|
||||
required: false,
|
||||
rule: 'Up to 200 characters, matched anywhere in the title, ignoring case and accents.',
|
||||
},
|
||||
{ name: 'status', type: 'string', required: false, rule: 'online or draft. Default both.' },
|
||||
{
|
||||
name: 'sort',
|
||||
type: 'string',
|
||||
required: false,
|
||||
rule: 'field:direction, with field title, status, created_at or updated_at and direction asc or desc. Default updated_at:desc.',
|
||||
},
|
||||
]
|
||||
|
||||
const MEDIA_QUERY: ApiField[] = [
|
||||
{ name: 'q', type: 'string', required: false, rule: 'Search text.' },
|
||||
{
|
||||
@@ -188,6 +207,23 @@ const ownerOrAdminErrors = (...own: ApiError[]) => [
|
||||
e(403, OWNER_OR_ADMIN_MESSAGE),
|
||||
]
|
||||
|
||||
const articlePage = () => ({
|
||||
items: [
|
||||
article(),
|
||||
article({
|
||||
id: 13,
|
||||
title: 'Choosing tiles for a small bathroom',
|
||||
body: 'Small rooms show every grout line.',
|
||||
is_online: false,
|
||||
updated_at: '2026-09-09T07:00:00Z',
|
||||
}),
|
||||
],
|
||||
total: 30,
|
||||
page: 1,
|
||||
size: 25,
|
||||
counts: { all: 30, online: 28, draft: 2 },
|
||||
})
|
||||
|
||||
const articleIdErrors = [e(400, ID_FORMAT), e(404, 'Article not found')]
|
||||
|
||||
const none: ApiField[] = []
|
||||
@@ -260,11 +296,11 @@ export const API_GROUPS: ApiGroup[] = [
|
||||
'art-list',
|
||||
'GET',
|
||||
'/v1/article/',
|
||||
'List articles. Anonymous callers get online articles only.',
|
||||
'List one page of articles, newest update first, with the total and the tab counts. Anonymous callers get online articles only.',
|
||||
'Public',
|
||||
articleErrors(),
|
||||
json([article()]),
|
||||
{ query: [FORMAT_QUERY] },
|
||||
articleErrors(e(400, BODY_MISMATCH)),
|
||||
json(articlePage()),
|
||||
{ query: ARTICLE_LIST_QUERY },
|
||||
),
|
||||
endpoint(
|
||||
'art-get',
|
||||
|
||||
Reference in new issue
Block a user