diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..a8b9b8b --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ['react', 'es2015', 'stage-1'], + "plugins": ['add-module-exports'] +} diff --git a/.gitignore b/.gitignore index ed72704..7d16503 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ public .gatsby-context.js .DS_Store +.intermediate-representation/ diff --git a/components/Bio.js b/components/Bio.js index 676d3c8..56b86e6 100644 --- a/components/Bio.js +++ b/components/Bio.js @@ -1,5 +1,4 @@ import React from 'react' -import { config } from 'config' import { rhythm } from 'utils/typography' import { prefixLink } from 'gatsby-helpers' import profilePic from './profile-pic.jpg' @@ -14,7 +13,7 @@ class Bio extends React.Component { > {`author - Written by {config.authorName} who lives and works in San Francisco building useful things. You should follow him on Twitter + Written by TODO author name who lives and works in TODO San Francisco building useful things. You should follow him on Twitter

) } diff --git a/components/ReadNext.js b/components/ReadNext.js index 6e60ba3..59b86ea 100644 --- a/components/ReadNext.js +++ b/components/ReadNext.js @@ -1,37 +1,20 @@ -import React from 'react' -import { Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import { prune, include as includes } from 'underscore.string' -import find from 'lodash/find' -import { rhythm, fontSizeToMS } from 'utils/typography' +const React = require('react') +const { Link } = require('react-router') -class ReadNext extends React.Component { +const { rhythm, adjustFontSizeToMSValue } = require('utils/typography') + +const Component = React.createClass({ render () { - const { pages, post } = this.props - const { readNext } = post - let nextPost - if (readNext) { - nextPost = find(pages, (page) => - includes(page.path, readNext) - ) - } + const { nextPost } = this.props if (!nextPost) { - return React.createElement('noscript', null) + return null } else { - nextPost = find(pages, (page) => - includes(page.path, readNext.slice(1, -1)) - ) - // Create pruned version of the body. - const html = nextPost.data.body - const body = prune(html.replace(/<[^>]*>/g, ''), 200) - return (
@@ -39,32 +22,32 @@ class ReadNext extends React.Component {

- {nextPost.data.title} + {nextPost.frontmatter.title}

-

{body}

+

{nextPost.excerpt}


) } } -} +}) -ReadNext.propTypes = { - post: React.PropTypes.object.isRequired, - pages: React.PropTypes.array, -} +export default Component + +export const query = ` +readNext { + id + excerpt(pruneLength: 200) + frontmatter { + title + } +} +` -export default ReadNext diff --git a/gatsby-config.js b/gatsby-config.js new file mode 100644 index 0000000..d46145e --- /dev/null +++ b/gatsby-config.js @@ -0,0 +1,10 @@ +const config = { + siteMetadata: { + title: 'Gatsby Starter Blog', + author: 'Kyle Mathews', + homeCity: 'San Francisco', + }, + sources: `${__dirname}/pages/`, +} + +export default config diff --git a/gatsby-node.js b/gatsby-node.js new file mode 100644 index 0000000..34c2b8f --- /dev/null +++ b/gatsby-node.js @@ -0,0 +1,46 @@ +import _ from 'lodash' +import Promise from 'bluebird' +import path from 'path' + +exports.rewritePath = (parsedFilePath, metadata) => { + if (parsedFilePath.ext === 'md') { + return `/${parsedFilePath.dirname.split('---')[1]}/` + } +} + +exports.createPages = ({ graphql }) => ( + new Promise((resolve, reject) => { + const pages = [] + const blogPost = path.resolve('./page-templates/blog-post.js') + graphql(` + { + allMarkdown(first: 1000) { + edges { + node { + path + } + } + } + } + `) + .then(result => { + if (result.errors) { + console.log(result.errors) + reject(result.errors) + } + + // Create blog posts pages. + _.each(result.data.allMarkdown.edges, (edge) => { + if (edge.node.path !== '/404/') { + pages.push({ + path: edge.node.path, + component: blogPost, + }) + } + }) + + console.log(pages) + resolve(pages) + }) + }) +) diff --git a/html.js b/html.js index cd1c637..05dc687 100644 --- a/html.js +++ b/html.js @@ -3,8 +3,8 @@ import DocumentTitle from 'react-document-title' import { prefixLink } from 'gatsby-helpers' import { GoogleFont, TypographyStyle } from 'react-typography' import typography from './utils/typography' - -const BUILD_TIME = new Date().getTime() +import HTMLScripts from 'html-scripts' +import HTMLStyles from 'html-styles' module.exports = React.createClass({ displayName: 'HTML', @@ -15,11 +15,6 @@ module.exports = React.createClass({ const { body } = this.props const title = DocumentTitle.rewind() - let css - if (process.env.NODE_ENV === 'production') { - css =