feat: wire up The Latest feed — fetch imported WP posts from new /api/public/posts
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user