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

@@ -106,6 +106,27 @@ export default function ArticleFeed() {
}
}, []);
// Fetch imported WordPress posts for the feed
useEffect(() => {
let cancelled = false;
(async () => {
try {
const res = await fetch("/api/public/posts?limit=200", { cache: "no-store" });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const json = await res.json();
const items = Array.isArray(json?.items) ? (json.items as ArticleItem[]) : [];
if (!cancelled) setWpPosts(items);
} catch {
if (!cancelled) setWpPosts([]);
} finally {
if (!cancelled) setLoadingWp(false);
}
})();
return () => {
cancelled = true;
};
}, []);
const handleFeedModeChange = (mode: FeedMode) => {
setFeedMode(mode);
setPage(1);