feat: categories — pages, nav, home block, admin editor select

This commit is contained in:
Alexey Pavlov
2026-05-31 14:43:28 +03:00
parent 80325b4435
commit 14053131cd
5 changed files with 148 additions and 4 deletions
+12 -1
View File
@@ -19,9 +19,20 @@ async function call(path, options = {}) {
return res.json();
}
export async function listArticles({ limit = 20, offset = 0, tag } = {}) {
export async function listCategories() {
try { return await call('/api/categories', { next: { revalidate: 3600 } }); }
catch { return []; }
}
export async function getCategoryArticles(slug, { limit = 20, offset = 0 } = {}) {
try { return await call(`/api/categories/${slug}/articles?limit=${limit}&offset=${offset}`); }
catch { return []; }
}
export async function listArticles({ limit = 20, offset = 0, tag, category } = {}) {
const params = new URLSearchParams({ limit, offset });
if (tag) params.set('tag', tag);
if (category) params.set('category', category);
return call(`/api/articles?${params}`, { next: { revalidate: 60 } });
}