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

Commit e2e4e2e

Browse files
committed
Merge branch 'staging' into feature/33-previews
2 parents c73eb1a + e624b00 commit e2e4e2e

File tree

8 files changed

+68
-3
lines changed

8 files changed

+68
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Query partial: retrieve comment fields.
2+
const commentsFields = `
3+
edges {
4+
node {
5+
databaseId
6+
content(format: RENDERED)
7+
parentDatabaseId
8+
approved
9+
id
10+
date
11+
parentId
12+
type
13+
}
14+
}
15+
`
16+
export default commentsFields
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import commentsFields from './commentsFields'
2+
3+
// Query partial: retrieve comment post fields.
4+
const commentsPostFields = `
5+
comments(first: 10) {
6+
${commentsFields}
7+
}
8+
`
9+
export default commentsPostFields
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {gql} from '@apollo/client'
2+
import archivePageInfo from '../_partials/archivePageInfo'
3+
import commentsFields from '../_partials/commentsFields'
4+
5+
// Query: retrieve comments by post databaseId.
6+
const queryCommentsByPostId = gql`
7+
query GET_COMMENTS_BY_POST_ID(
8+
$id: ID!
9+
$first: Int
10+
$last: Int
11+
$after: String
12+
$before: String
13+
$order: OrderEnum = ASC
14+
$orderby: CommentsConnectionOrderbyEnum = COMMENT_DATE
15+
) {
16+
comments(
17+
first: $first
18+
last: $last
19+
after: $after
20+
before: $before
21+
where: {contentId: $id, order: $order, orderby: $orderby}
22+
) {
23+
${archivePageInfo}
24+
${commentsFields}
25+
}
26+
}
27+
`
28+
29+
export default queryCommentsByPostId

api/wordpress/posts/queryPostById.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tagsPostFields from '../_partials/tagsPostFields'
66
import categoriesPostFields from '../_partials/categoriesPostFields'
77
import {gql} from '@apollo/client'
88
import defaultPageData from '../_partials/defaultPageData'
9+
import commentsPostFields from '../_partials/commentsPostFields'
910

1011
// Fragment: retrieve single post fields.
1112
const singlePostFragment = gql`
@@ -18,6 +19,7 @@ const singlePostFragment = gql`
1819
${featuredImagePostFields}
1920
${tagsPostFields}
2021
${categoriesPostFields}
22+
${commentsPostFields}
2123
}
2224
`
2325
// Query: retrieve post by specified identifier.

components/blocks/BlockHeadings/BlockHeadings.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import React from 'react'
99
* The core Headings block from Gutenberg.
1010
*
1111
* @author WebDevStudios
12-
* @param {object} props The component attributes as props.
12+
* @param {object} props The component attributes as props.
13+
* @param {object} props.props The block attributes props from WordPress.
14+
* @return {Element} RichText component with heading content.
1315
*/
1416
export default function BlockHeadings({props}) {
1517
const {anchor, align, className, content, level} = props

components/blocks/BlockParagraph/BlockParagraph.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import PropTypes from 'prop-types'
88
* The core Paragraph block from Gutenberg.
99
*
1010
* @author WebDevStudios
11-
* @param {object} props The component attributes as props.
11+
* @param {object} props The component attributes as props.
12+
* @param {object} props.props The block attributes props from WordPress.
13+
* @return {Element} RichText component with paragraph content.
1214
*/
1315
export default function BlockParagraph({props}) {
1416
const {className, align, anchor, content} = props

components/molecules/Blocks/Blocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import displayBlock from '@/functions/displayBlock'
77
*
88
* @author WebDevStudios
99
* @param {object} props The component attributes as props.
10-
* @param {array} props.blocks The array of blocks.
10+
* @param {Array} props.blocks The array of blocks.
1111
* @return {Element} The Blocks component.
1212
*/
1313
export default function Blocks({blocks}) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export default function BlogPost({post, archive, posts, pagination}) {
6464
<Layout seo={{...post?.seo}} hasJsonLd={true}>
6565
<article className="container">
6666
<Blocks blocks={post?.blocks} />
67+
<div
68+
dangerouslySetInnerHTML={{
69+
__html: JSON.stringify(post?.comments ?? [])
70+
}}
71+
/>
6772
</article>
6873
</Layout>
6974
)

0 commit comments

Comments
 (0)