Latest Blog Posts
+ {data?.posts?.length ? ( +-
+ {data.posts.map((post) => (
+
- + + {post.title.rendered} + + + ))} +
No posts found.
+ )} +diff --git a/test-projects/next/pages/blog.tsx b/test-projects/next/pages/blog.tsx new file mode 100644 index 000000000..20ef62f7c --- /dev/null +++ b/test-projects/next/pages/blog.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import { usePosts } from "@headstartwp/next"; // hook from headstartwp + +export default function BlogPage() { + const { data, isLoading, error } = usePosts({ + perPage: 5, + }); + + if (isLoading) return
Loading posts...
; + if (error) returnFailed to load posts.
; + + return ( +No posts found.
+ )} +