Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit c6a0143

Browse files
committed
Add comment test to blog posts
1 parent 9999cda commit c6a0143

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pages/blog/[[...slug]].js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticPro
33
import Layout from '@/components/common/Layout'
44
import Link from 'next/link'
55
import getArchivePosts from '@/api/frontend/wp/archive/getArchivePosts'
6+
import postComment from '@/api/frontend/wp/comments/postComment'
67
import getPagePropTypes from '@/functions/getPagePropTypes'
78
import Blocks from '@/components/molecules/Blocks'
89

@@ -29,6 +30,20 @@ export default function BlogPost({post, archive, posts, pagination}) {
2930
await getArchivePosts(postType, pagination?.endCursor)
3031
}
3132

33+
/**
34+
* Post a comment back to the blog
35+
*/
36+
async function postTestComment() {
37+
// TODO: get form data and post the comment
38+
await postComment(
39+
'Test Testerson',
40+
41+
'https://nextjswp.test',
42+
post.databaseId,
43+
'This is a test comment.'
44+
)
45+
}
46+
3247
// Check for post archive.
3348
// TODO create generic archive component and move this check to `_app.js`.
3449
if (archive) {
@@ -69,6 +84,7 @@ export default function BlogPost({post, archive, posts, pagination}) {
6984
__html: JSON.stringify(post?.comments ?? [])
7085
}}
7186
/>
87+
<button onClick={postTestComment}>Post test comment</button>
7288
</article>
7389
</Layout>
7490
)

0 commit comments

Comments
 (0)