ivanlopez / expresspress

A demonstration of how to write an Express site with content from WordPress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.
  1. Visit http://localhost:3000 (or whatever port you specified) to view your site
  2. 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!

About

A demonstration of how to write an Express site with content from WordPress

License:MIT License