feat: wire up The Latest feed — fetch imported WP posts from new /api/public/posts

This commit is contained in:
claude-code
2026-05-16 12:56:16 +00:00
parent e4e74a9059
commit 39311a4401
3 changed files with 89 additions and 0 deletions

View File

@@ -414,3 +414,24 @@ export async function getRecentAiRewrites(limit = 20): Promise<Article[]> {
const rows = await fetchPublishedRewrites(limit);
return rows.map((r) => rewriteRowToArticle(r));
}
export async function getLatestImportedArticles(
limit = 100,
offset = 0,
): Promise<{ items: Article[]; total: number }> {
try {
const { data, error, count } = await client()
.from("wp_imported_posts")
.select(SELECT_COLS, { count: "exact" })
.eq("status", "published")
.order("wp_published_at", { ascending: false, nullsFirst: false })
.range(offset, offset + limit - 1);
if (error || !data) return { items: [], total: 0 };
return {
items: (data as ImportedPostRow[]).map((r) => rowToArticle(r)),
total: count ?? data.length,
};
} catch {
return { items: [], total: 0 };
}
}