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