Skip to content

Commit

Permalink
Update cms-wordpress example (#34944)
Browse files Browse the repository at this point in the history
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
lydiahallie and ijjk committed Mar 2, 2022
1 parent 21c07eb commit abe4936
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions examples/cms-wordpress/components/more-stories.js
Expand Up @@ -11,9 +11,9 @@ export default function MoreStories({ posts }) {
<PostPreview
key={node.slug}
title={node.title}
coverImage={node.featuredImage?.node}
coverImage={node.featuredImage}
date={node.date}
author={node.author?.node}
author={node.author}
slug={node.slug}
excerpt={node.excerpt}
/>
Expand Down
28 changes: 9 additions & 19 deletions examples/cms-wordpress/lib/api.js
Expand Up @@ -70,18 +70,14 @@ export async function getAllPostsForHome(preview) {
slug
date
featuredImage {
node {
sourceUrl
}
sourceUrl
}
author {
node {
name
firstName
lastName
avatar {
url
}
name
firstName
lastName
avatar {
url
}
}
}
Expand Down Expand Up @@ -125,14 +121,10 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
slug
date
featuredImage {
node {
sourceUrl
}
sourceUrl
}
author {
node {
...AuthorFields
}
...AuthorFields
}
categories {
edges {
Expand Down Expand Up @@ -164,9 +156,7 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
excerpt
content
author {
node {
...AuthorFields
}
...AuthorFields
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions examples/cms-wordpress/next.config.js
@@ -0,0 +1,8 @@
module.exports = {
images: {
domains: [
// "[yourapp].wpengine.com" (Update this to be your Wordpress application name in order to load images connected to your posts)
'secure.gravatar.com',
],
},
}
5 changes: 3 additions & 2 deletions examples/cms-wordpress/pages/index.js
Expand Up @@ -22,9 +22,9 @@ export default function Index({ allPosts: { edges }, preview }) {
{heroPost && (
<HeroPost
title={heroPost.title}
coverImage={heroPost.featuredImage?.node}
coverImage={heroPost.featuredImage}
date={heroPost.date}
author={heroPost.author?.node}
author={heroPost.author}
slug={heroPost.slug}
excerpt={heroPost.excerpt}
/>
Expand All @@ -38,6 +38,7 @@ export default function Index({ allPosts: { edges }, preview }) {

export async function getStaticProps({ preview = false }) {
const allPosts = await getAllPostsForHome(preview)

return {
props: { allPosts, preview },
}
Expand Down
6 changes: 3 additions & 3 deletions examples/cms-wordpress/pages/posts/[slug].js
Expand Up @@ -36,14 +36,14 @@ export default function Post({ post, posts, preview }) {
</title>
<meta
property="og:image"
content={post.featuredImage?.node?.sourceUrl}
content={post.featuredImage?.sourceUrl}
/>
</Head>
<PostHeader
title={post.title}
coverImage={post.featuredImage?.node}
coverImage={post.featuredImage}
date={post.date}
author={post.author?.node}
author={post.author}
categories={post.categories}
/>
<PostBody content={post.content} />
Expand Down

0 comments on commit abe4936

Please sign in to comment.