There is a bug in the cms-wordpress example due to a Wordpress plugin dependency. After running `npm install`, then either `npm run dev` or `npm run build`, the following errors appear in the console:
```shell
> cms-wordpress@1.0.0 dev /Users/jplew/Sites/projects/next.js/examples/cms-wordpress
> next
ready - started server on http://localhost:3000
info - Loaded env from /Users/jplew/Sites/projects/next.js/examples/cms-wordpress/.env.local
event - compiled successfully
event - build page: /
wait - compiling...
event - build page: /next/dist/pages/_error
event - compiled successfully
[
{
message: 'Cannot query field "name" on type "NodeWithAuthorToUserConnectionEdge". Did you mean "node"?',
extensions: { category: 'graphql' },
locations: [ [Object] ]
},
{
message: 'Cannot query field "firstName" on type "NodeWithAuthorToUserConnectionEdge".',
extensions: { category: 'graphql' },
locations: [ [Object] ]
},
{
message: 'Cannot query field "lastName" on type "NodeWithAuthorToUserConnectionEdge".',
extensions: { category: 'graphql' },
locations: [ [Object] ]
},
{
message: 'Cannot query field "avatar" on type "NodeWithAuthorToUserConnectionEdge".',
extensions: { category: 'graphql' },
locations: [ [Object] ]
}
]
Error: Failed to fetch API
at fetchAPI (webpack-internal:///./lib/api.js:31:11)
```
The reason for this is `wp-graphql` released version v0.10.0 ten days ago which introduced a number of breaking changes (https://github.com/wp-graphql/wp-graphql/releases/tag/v0.10.0). Specifically, this is the change that breaks the current example:
> - One to One relationships are now nested. For example post.author and post.featuredImage now return an edge/node instead of the node directly.
More info about this change can be found here: https://github.com/wp-graphql/wp-graphql/issues/347#issuecomment-639071772
After my changes, `npm run dev` and `npm run build` succeed without errors.
Preview of existing posts should always return the latest revision so DESC sorting was required. Otherwise, it would always return the oldest revision.
Tested against latest Wordpress and GraphQL plugins on drafts, published, and edited but unpublished changes. The example works great!
* added graphcms
* Updated readme and environment variables
* Removed gitignore
* Updated tailwind config
* Some fixes in pages
* Updated api endpoints
* lint fix
* Updated readme
* Updated og image
* Updated cms examples to include this one
* Added example to docs
* Added preview demo link
* Updated step
Co-authored-by: Luis Alvarez <luis@vercel.com>
[ch2502]
- Added new import flow to every CMS example, using the deploy button, and removed `vercel.json`
- Replaced `dotenv` with the new env support in outdated examples
[ch579]
Some README files in `examples/cms-*` were linking to a documentation markdown file inside the repo (e.g. `/docs/basic-features/pages.md`) instead of the documentation website. We should always link to the documentation website from an example README file because (1) the website has better UX and (2) as we’re creating the examples pages on `next-site` (https://github.com/vercel/next-site/pull/672), we’d like to avoid extra processing of markdown content.
* Add Cosmic CMS Example
* with native .env support, this file isn't needed anymore
* FIX use path alias
* Add cosmicjs package
* Fix alias import in pages/api/preview
* Added: react-imgix & lazysizes package
* Load lazysizes in layout
* Used imgix image with lazyloading
* Added avatar imgix optimizations
* EDITED: steps to install content, preview
* EDITED: demo link
* EDITED: Install step
* EDITED: preview link steps
* Edited: demo link
* FIXED: object_slug
* Screenshots
* Fixed object_slug link
* Update README.md
* Fix: formatting issue
* Updated readme and renamed .env to env.local
* Sanity checks
* Handle fallback data when expected
* Added link to the example in other examples
* Updated demo deployment
* Added example to docs
* minor lint fix
* Remove manual download step
* use vercel.json
Co-authored-by: Tony Spiro <tspiro@tonyspiro.com>
Co-authored-by: Luis Alvarez <luis@vercel.com>