diff --git a/gatsby-node.js b/gatsby-node.js index 882a36a..4abb8cb 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -17,6 +17,20 @@ exports.createPages = ({ graphql, boundActionCreators }) => { } } ` - ) + ).then(result => { + if (result.errors) { + console.log(result.errors) + reject(result.errors) + } + + result.data.allWordpressPage.edges.forEach(({ node }) => { + createPage({ + path: node.slug, + component: path.resolve('./src/pages/page.js'), + }) + }) + + resolve() + }) }) } diff --git a/src/components/header.js b/src/components/header.js new file mode 100644 index 0000000..3aa8008 --- /dev/null +++ b/src/components/header.js @@ -0,0 +1,18 @@ +import React from 'react' +import Link from 'gatsby-link' + +const Header = ({ siteTitle }) => ( +

+ + {siteTitle} + +

+) + +export default Header diff --git a/src/layouts/index.js b/src/layouts/index.js new file mode 100644 index 0000000..967ad71 --- /dev/null +++ b/src/layouts/index.js @@ -0,0 +1,35 @@ +import React from 'react' +import PropTypes from 'prop-types' +import Helmet from 'react-helmet' + +import Header from '../components/header' + +const Layout = ({ children, data }) => ( +
+ +
+ {children()} +
+) + +Layout.propTypes = { + children: PropTypes.func, +} + +export default Layout + +export const query = graphql` + query SiteTitleQuery { + site { + siteMetadata { + title + } + } + } +` diff --git a/src/pages/404.js b/src/pages/404.js new file mode 100644 index 0000000..a091a00 --- /dev/null +++ b/src/pages/404.js @@ -0,0 +1,10 @@ +import React from 'react' + +const NotFoundPage = () => ( +
+

NOT FOUND

+

You just hit a route that doesn't exist... the sadness.

+
+) + +export default NotFoundPage diff --git a/src/pages/index.js b/src/pages/index.js new file mode 100644 index 0000000..9cb1423 --- /dev/null +++ b/src/pages/index.js @@ -0,0 +1,9 @@ +import React from 'react' + +const IndexPage = () => ( +
+

Index page

+
+) + +export default IndexPage diff --git a/src/pages/page.js b/src/pages/page.js new file mode 100644 index 0000000..de47507 --- /dev/null +++ b/src/pages/page.js @@ -0,0 +1,24 @@ +import React, { Component } from 'react'; + +class Page extends Component { + render() { + const { data } = this.props + return ( +
+

Specific Page - {data.wordpressPage.title}

+
+ ); + } +} + +export const query = graphql` + query PageQuery { + wordpressPage(slug: {eq: "about"}) { + title + slug + content + } + } +` + +export default Page; \ No newline at end of file