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

Commit ec97576

Browse files
author
Greg Rickaby
authored
Merge pull request #19 from WebDevStudios/bugfix/wpgraphql-version-increase-17
Modify code to compensate for WPGraphQL breaking changes
2 parents d6e6a79 + 59318e8 commit ec97576

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

components/avatar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import PropTypes from 'prop-types'
22

33
export default function Avatar({author}) {
44
const name =
5-
author.firstName && author.lastName
6-
? `${author.firstName} ${author.lastName}`
7-
: author.name
5+
author.node.firstName && author.node.lastName
6+
? `${author.node.firstName} ${author.node.lastName}`
7+
: author.node.name
88

99
return (
1010
<div className="flex items-center">
1111
<img
12-
src={author.avatar.url}
12+
src={author.node.avatar.url}
1313
className="w-12 h-12 rounded-full mr-4"
1414
alt={name}
1515
/>

components/cover-image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Link from 'next/link'
55
export default function CoverImage({title, coverImage, slug}) {
66
const image = (
77
<img
8-
src={coverImage?.sourceUrl}
8+
src={coverImage?.node?.sourceUrl}
99
className={cn('shadow-small', {
1010
'hover:shadow-medium transition-shadow duration-200': slug
1111
})}

lib/api.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ export async function getAllPostsForHome(preview) {
7171
slug
7272
date
7373
featuredImage {
74-
sourceUrl
74+
node {
75+
sourceUrl
76+
}
7577
}
7678
author {
77-
name
78-
firstName
79-
lastName
80-
avatar {
81-
url
79+
node {
80+
name
81+
firstName
82+
lastName
83+
avatar {
84+
url
85+
}
8286
}
8387
}
8488
}
@@ -122,10 +126,14 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
122126
slug
123127
date
124128
featuredImage {
125-
sourceUrl
129+
node {
130+
sourceUrl
131+
}
126132
}
127133
author {
128-
...AuthorFields
134+
node {
135+
...AuthorFields
136+
}
129137
}
130138
categories {
131139
edges {
@@ -157,7 +165,9 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
157165
excerpt
158166
content
159167
author {
160-
...AuthorFields
168+
node {
169+
...AuthorFields
170+
}
161171
}
162172
}
163173
}

pages/posts/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function Post({post, posts, preview}) {
3737
</title>
3838
<meta
3939
property="og:image"
40-
content={post.featuredImage?.sourceUrl}
40+
content={post.featuredImage?.node?.sourceUrl}
4141
/>
4242
</Head>
4343
<PostHeader

0 commit comments

Comments
 (0)