Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted CoffeeScript and CJSX to ES6 and JSX #1

Merged
merged 10 commits into from Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions app.coffee

This file was deleted.

11 changes: 11 additions & 0 deletions app.js
@@ -0,0 +1,11 @@
exports.loadContext = function(callback) {
var context;
context = require.context('./pages', true);
if (module.hot) {
module.hot.accept(context.id, function() {
context = require.context('./pages', true);
return callback(context);
});
}
return callback(context);
};
50 changes: 0 additions & 50 deletions components/ReadNext.cjsx

This file was deleted.

56 changes: 56 additions & 0 deletions components/ReadNext.jsx
@@ -0,0 +1,56 @@
import React from 'react';
import { Link } from 'react-router';
import { prune, include as includes } from 'underscore.string';
import find from 'lodash/collection/find';

module.exports = React.createClass({
render: function() {
var body, fontSizeToMS, html, nextPost, readNext, ref, rhythm;
ref = this.props.typography, rhythm = ref.rhythm, fontSizeToMS = ref.fontSizeToMS;
readNext = this.props.post.readNext;
if (readNext != null) {
nextPost = find(this.props.pages, function(page) {
return includes(page.path, readNext.slice(1, -1));
});
}
if (!nextPost) {
return React.createElement("noscript", null);
} else {
nextPost = find(this.props.pages, function(page) {
return includes(page.path, readNext.slice(1, -1));
});
// Create pruned version of the body.
html = nextPost.data.body;
body = prune(html.replace(/<[^>]*>/g, ''), 200);

return (
<div>
<h6
style={{
margin: 0,
fontSize: fontSizeToMS(-1).fontSize,
lineHeight: fontSizeToMS(-1).lineHeight,
letterSpacing: -0.5
}}
>
READ THIS NEXT:
</h6>
<h3
style={{
marginBottom: rhythm(1/4)
}}
>
<Link
to={nextPost.path}
query={{readNext: true}}
>
{nextPost.data.title}
</Link>
</h3>
<p>{body}</p>
<hr />
</div>
);
}
}
});
49 changes: 0 additions & 49 deletions html.cjsx

This file was deleted.

61 changes: 61 additions & 0 deletions html.jsx
@@ -0,0 +1,61 @@
import React from 'react';
import Typography from 'typography';
import DocumentTitle from 'react-document-title';

var TypographyStyle = new Typography().TypographyStyle;

module.exports = React.createClass({
getDefaultProps: function() {
return {
body: ""
};
},

render: function() {
var title, urlPrefix;
title = DocumentTitle.rewind();
if (this.props.title) {
title = this.props.title;
}
if ((typeof __GH_PAGES__ !== "undefined" && __GH_PAGES__ !== null) && __GH_PAGES__) {
urlPrefix = this.props.config.ghPagesURLPrefix;
} else {
urlPrefix = "";
}

return (
<html lang="en">
<head>
<meta charSet="utf-8"/>
<meta httpEquiv="X-UA-Compatible" content="IE=edge"/>
<meta name='viewport' content='user-scalable=no width=device-width, initial-scale=1.0 maximum-scale=1.0'/>
<title>{this.props.title}</title>
<link rel="shortcut icon" href={this.props.favicon}/>
<TypographyStyle/>
<style dangerouslySetInnerHTML={{__html:
`
body {
color: rgb(66,66,66);
}
h1,h2,h3,h4,h5,h6 {
color: rgb(44,44,44);
}
a {
color: rgb(42,93,173);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
`
}}/>
</head>
<body className="landing-page">
<div id="react-mount" dangerouslySetInnerHTML={{__html: this.props.body}} />
<script src={urlPrefix + "/bundle.js"}/>
</body>
</html>
);

}
});
58 changes: 0 additions & 58 deletions pages/_template.cjsx

This file was deleted.

62 changes: 62 additions & 0 deletions pages/_template.jsx
@@ -0,0 +1,62 @@
import React from 'react';
import { RouteHandler, Link } from 'react-router';
import { Container, Grid, Breakpoint, Span } from 'react-responsive-grid';
import Typography from 'typography';
import { link } from 'gatsby-helpers';

var typography = new Typography();
var rhythm = typography.rhythm, fontSizeToMS = typography.fontSizeToMS;

import '../css/styles.css';

module.exports = React.createClass({
render: function() {
var header;
if (this.props.state.path === link('/')) {
header = (
<h1
style={{
fontSize: fontSizeToMS(2.5).fontSize,
lineHeight: fontSizeToMS(2.5).lineHeight,
marginBottom: rhythm(1.5)
}}
>
<Link
style={{
textDecoration: 'none',
color: 'inherit'
}}
to={link('/')}
>
{this.props.config.blogTitle}
</Link>
</h1>
);
} else {
header = (
<h3>
<Link
style={{
textDecoration: 'none',
color: 'inherit'
}}
to={link('/')}
>
{this.props.config.blogTitle}
</Link>
</h3>
);
}
return (
<Container
style={{
maxWidth: rhythm(24),
padding: `${rhythm(2)} ${rhythm(1/2)}`
}}
>
{header}
<RouteHandler typography={typography} {...this.props}/>
</Container>
);
}
});