GithubHelp home page GithubHelp logo

notepadwebdev / gatsby-wordpress-acf-graphql Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 9.26 MB

Boilerplate for GatsbyJS site sourcing data from WordPress with ACF, and GraphQL plugins.

JavaScript 17.64% CSS 0.09% PHP 81.29% Hack 0.01% Shell 0.01% SCSS 0.55% TypeScript 0.42% HTML 0.01%

gatsby-wordpress-acf-graphql's Introduction

Gatsby WordPress (ACF, GraphQL)

Minimal implementation of GatsbyJS site sourcing data from WordPress with Gatsby Source Wordpress Experimental.

The previous official gatsby-source-wordpress will soon be deprecated, to be replaced with the new plugin which moves away from the WP Rest API and has "adopted the use of WPGraphQL to support Preview and incremental builds as well as to make the schema generally more stable and consistent".

Uses Docker to run WordPress, MySQL and phpMyAdmin. ๐Ÿณ

Setup

git clone [email protected]:notepadwebdev/gatsby-wordpress-acf-graphql.git

Install and set up WordPress

Install Docker (if you don't already have it), and start the Docker app.

From the wordpress directory, do the following...

  1. Start the Docker container
docker-compose up -d
  1. When complete (can take a few of minutes - especially first time) go to http://localhost:8888/ and complete the usual WordPress install.
  2. Once installed, log into WordPress and enable the included plugins in the following order...
  3. Switch theme to the provided Gatsby WP (CMS only) theme.
  4. Make sure that WP permalinks are setup correctly. Settings => Permalinks => choose Post name and save.
  5. (Optional) Create a new Primary Navigation menu, and add default WordPress pages to it. Make sure you tick the checkbox to add it to the Primary Navigation display location.
  6. (Optional) Enable Gatsby preview from the GatsbyJS settings page.

Install and set up Gatsby

Install Gatsby CLI globally (if you don't already have it).

npm install -g gatsby-cli

From the gatsby directory, switch to an appropriate node version then install project dependencies.

nvm use
npm install

Environment Variables (optional)

Environment Variables can be used to manage details across environments.
Create a new .env.development file based on the provided .env.example example. Use this to set your own GraphQL endpoint if you decide to source from a different WordPress instance. Replace the following with your own endpoint URL...

WPGRAPHQL_URL=http://localhost:8888/graphql

Development

Wordpress

From the wordpress directory, run the following command to start the Docker container

docker-compose up -d

Check that your /graphql endpoint is accessible. You should see the following errors response when you view the endpoint in your browser. If not, then something went wrong.

{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"","extensions":{"category":"request"}}]}

Gatsby WP theme

  • CMS only, no front end.
  • ACF Local JSON enabled with simple implementation of Flexible Content area added for all WP pages.
  • A "Primary Navigation" menu container example included (with associated Gatsby component).
  • Classic Editor instead of Gutenberg.
  • A reduced Admin UI.
  • Docker volume for ./wp-content for your plugins, themes, and uploads.

Gatsby

From the gatsby directory, run the following command to build the site and start the Gatsby web server. Hot reloading is enabled.

npm start

View the GatsbyJS site at http://localhost:8000/.

Index page includes a list of links to all WP pages and posts. Create new pages and posts to see them appear on the Gatsby site homepage (when Gatsby preview is enabled).

Local Development URLs

Gatsby: http://localhost:8000/

GraphiQL: http://localhost:8000/___graphql

WordPress (CMS only): http://localhost:8888/wp-admin/

phpMyAdmin: http://localhost:3333/ user: wordpress pass: wordpress

gatsby-wordpress-acf-graphql's People

Watchers

 avatar  avatar

Forkers

vyne-digital

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.