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

Fix for 1602 #1604

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/gatsby-source-wordpress/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# gatsby-source-wordpress

Source plugin for pulling data into [Gatsby](https://github.com/gatsbyjs) from Wordpress sites using the [Wordpress JSON REST API](https://developer.wordpress.org/rest-api/reference/).
Source plugin for pulling data into [Gatsby](https://github.com/gatsbyjs) from WordPress sites using the [WordPress JSON REST API](https://developer.wordpress.org/rest-api/reference/).

An example site for using this plugin will be published soon as this is a WIP.

## WIP

- [x] source plugin
- [x] pull data from self-hosted wordpress
- [x] pull data from self-hosted WordPress
- [x] pull data from site hosted on wordpress.com, wordpress.org
- [ ] authentify to wordpress.com API so medias can be queried.
- [ ] pull images to local file system [WIP]
- [ ] responsive images using sharp

## Status

This module is at prototype-level. It currently pulls from Wordpress the following entities :
This module is at prototype-level. It currently pulls from WordPress the following entities :
- [x] posts
- [x] pages
- [x] tags
Expand All @@ -27,14 +27,14 @@ This module is at prototype-level. It currently pulls from Wordpress the followi
- [x] taxonomies
- [x] and entities exposed by other plugins

It will pull any endpoint provided by Wordpress Plugins as long as it appears in the list of endpoints.
* `//your-site.com/wp-json/` for a self-hosted wordpress or hosted on wordpress.org
It will pull any endpoint provided by WordPress Plugins as long as it appears in the list of endpoints.
* `//your-site.com/wp-json/` for a self-hosted WordPress or hosted on wordpress.org
* `https://public-api.wordpress.com/wp/v2/sites/your-site.com` for a site hosted on wordpress.com

Currently only these plugins were tested but it should work with any.
- [x] [ACF](https://www.advancedcustomfields.com/) As this is a special plugin, this must be activated with `useACF: true` in your site's `gatsby-config.js`.
* You must have the plugin [acf-to-rest-api](https://github.com/airesvsg/acf-to-rest-api) installed in Wordpress in order to be able to access the ACF Fields from the API (this is the only known way to do that).
* Will pull the `acf: { ... }` fields's contents from any entity which has it attached (pages, posts, medias, ... you choose from in Wordpress back-end while creating a Group of Fields). Every node below `acf` is [Stringify'd](https://www.w3schools.com/js/js_json_stringify.asp), then put in a childNode, which means that you will have to call `JSON.parse()` to get an `Object`. (ex. ```const fields = JSON.parse(childWordpressAcfField.internal.content)```)
* You must have the plugin [acf-to-rest-api](https://github.com/airesvsg/acf-to-rest-api) installed in WordPress in order to be able to access the ACF Fields from the API (this is the only known way to do that).
* Will pull the `acf: { ... }` fields's contents from any entity which has it attached (pages, posts, medias, ... you choose from in WordPress back-end while creating a Group of Fields). Every node below `acf` is [Stringify'd](https://www.w3schools.com/js/js_json_stringify.asp), then put in a childNode, which means that you will have to call `JSON.parse()` to get an `Object`. (ex. ```const fields = JSON.parse(childWordpressAcfField.internal.content)```)
* You will also have to include the children ACF Field Node in your GraphQL query. (See `Query posts with the child ACF Fields Node` below)

- [x] [ACF Pro](https://www.advancedcustomfields.com/pro/)
Expand Down Expand Up @@ -473,13 +473,13 @@ const slash = require(`slash`)
// called after the Gatsby bootstrap is finished so you have
// access to any information necessary to programatically
// create pages.
// Will create pages for Wordpress pages (route : /{slug})
// Will create pages for Wordpress posts (route : /post/{slug})
// Will create pages for WordPress pages (route : /{slug})
// Will create pages for WordPress posts (route : /post/{slug})
exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
return new Promise((resolve, reject) => {
// The “graphql” function allows us to run arbitrary
// queries against the local Wordpress graphql schema. Think of
// queries against the local WordPress graphql schema. Think of
// it like the site has a built-in database constructed
// from the fetched data that you can run queries against.

Expand Down Expand Up @@ -511,7 +511,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
// Create Page pages.
const pageTemplate = path.resolve('./src/templates/page.js')
// We want to create a detailed page for each
// page node. We'll just use the Wordpress Slug for the slug.
// page node. We'll just use the WordPress Slug for the slug.
// The Page ID is prefixed with 'PAGE_'
_.each(result.data.allWordpressPage.edges, edge => {
// Gatsby uses Redux to manage its internal state.
Expand Down Expand Up @@ -557,7 +557,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
}
const postTemplate = path.resolve('./src/templates/post.js')
// We want to create a detailed page for each
// post node. We'll just use the Wordpress Slug for the slug.
// post node. We'll just use the WordPress Slug for the slug.
// The Post ID is prefixed with 'POST_'
_.each(result.data.allWordpressPost.edges, edge => {
createPage({
Expand Down