-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return config from queryPostOrPosts (#850)
- Loading branch information
1 parent
3a97506
commit 9ea83c3
Showing
5 changed files
with
51 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@headstartwp/core": patch | ||
"@headstartwp/next": patch | ||
--- | ||
|
||
Fix: return config from queryPostOrPosts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
projects/wp-nextjs-app/src/components/ServerRelatedPosts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { queryPosts } from '@headstartwp/next/app'; | ||
import { FC } from 'react'; | ||
|
||
export const ServerRelatedPosts: FC<{ post_id: number; category: string }> = async ({ | ||
post_id, | ||
category, | ||
}) => { | ||
const { data } = await queryPosts({ | ||
params: { postType: 'post', per_page: 3, category, exclude: [post_id] }, | ||
}); | ||
|
||
return ( | ||
<div> | ||
<h2>Related Posts (Streamed from Server)</h2> | ||
<ul> | ||
{data.posts.map((post) => ( | ||
<li key={post.id}>{post.title.rendered}</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; |