@elricb/wordpress-react-router

1.0.0 • Public • Published

Wordpress-React-Router

TODO setup a test page (build-location) and test wordpress site to point to.

Webpack

I'm partial to webpack code splitting, so I use webpack System.import in the examples. Reinterpret to suit your different build system needs.

WordpressRouter

Loads markup from Wordpress Page. If an override component exists, loads component and passes in Wordpress Page json through props.

//output from wp-json (minified/saved)
import siteConfig from 'config/site.json';
import MyContainer from 'somewhere/my-container';

let wordpressUrl = 'http://mysite/wordpress-path/wp-json',
    wordpressData = new WordpressData(wordpressUrl, siteConfig),
    wordpressPage = window.location.pathname.split('/')[1] || '',
    componentPromise = import('./route/' + wordpressPage + '/index.jsx');

return (
    <MyContainer>
        <WordpressRouter
            wordpressData={wordpressData}
            wordpressPage={wordpressPage}
            wordpressComponent={componentPromise}
        />
    </MyContainer>
);

Setup

Wordpress

You'll need Wordpress installed with plugin REST API 2 or greater.

Webserver

Your server will need to interpret paths and point them back to your React index page.

Sample

tbd

Readme

Keywords

Package Sidebar

Install

npm i @elricb/wordpress-react-router

Weekly Downloads

1

Version

1.0.0

License

ISC

Last publish

Collaborators

  • elricb