feat: categories — pages, nav, home block, admin editor select
This commit is contained in:
+12
-1
@@ -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 } });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user