Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cms-wordpress example #34944

Merged
merged 6 commits into from Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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