A demonstration of how to write an Express site with content from WordPress
JavaScript CSS
Latest commit df9e580 May 25, 2015 K. Adam White Add nodemon to dev dependencies (fixes #14)
Failed to load latest commit information.
bin
middleware Show a featured image on the single-post view Oct 15, 2014
public Fix lint errors (whoops) Oct 25, 2014
routes Add category archive Oct 25, 2014
services Add category archive Oct 25, 2014
views Render HTML entities in category archive headers Jan 13, 2015
.gitignore Add a single page route and render latest on homepage Oct 15, 2014
.jscsrc
.jshintrc Fix lint errors (whoops) Oct 25, 2014
Gruntfile.js
LICENSE Initial commit Oct 14, 2014
README.md
app.js
nodemon.json Auto-reload on config.yml updates Oct 25, 2014
package.json Add nodemon to dev dependencies (fixes #14) May 25, 2015

README.md

ExpressPress

This project is a demonstration of how WordPress can be used to provide content for an application written in Node.js, a server-side JavaScript runtime. WordPress is a mature and powerful content management system, with a longer history and better non-developer usability than many of the options available natively in Node. With the help of the WordPress REST API plugin (which is targeted for integration with WordPress core some time in 2015), you can leverage the excellent content-editing interface and data store of WordPress from any Node app.

ExpressPress itself is a lightweight blog viewer, which will serve the content from your WP-API-enabled WordPress site. It uses the wordpress-rest-api NPM module to query resources under the WP-API endpoint.

Installation

To run ExpressPress locally (which we recommend, as this is first and foremost a learning resource), follow the following steps.

  1. Clone this repository
  2. Install Node.js (On OSX, we recommend installing Node via Homebrew)
  3. Inside the cloned repository directory, run npm install to install the dependencies
  4. Create a file called "config.yml" within the repository directory, with the following content (see the WP-API project for instructions on installing and enabling the API plugin):

      # careful: yaml syntax requires spaces, NOT tabs!
      wordpress:
        endpoint: 'http://www.your-api-enabled-wp-site.com/wp-json'
        cacheLimit: 3600000 # 1000ms * 60s * 60m = 1hr
  5. From the command-line, run npm start to run the application.
    • To run on a specific port, run PORT=XXXX npm start, where XXXX is a valid http port e.g. 8080.
  6. Visit http://localhost:3000 (or whatever port you specified) to view your site
  7. Alter the code, learn how it works, add new routes, & experiment! The server will automatically restart if you change any server-side files.

Credits

Thanks to Tim Branyen, Carl Danley, Irene Ros, Brendan McLoughlin and everyone else at Bocoup for their assistance in reviewing and supporting this project!