Skip to content

Instantly share code, notes, and snippets.

View astrotim's full-sized avatar

Tim Holt astrotim

View GitHub Profile
language: node_js
node_js:
- "node"
cache:
- yarn
install:
- yarn install
script:
- yarn build
deploy:
import React, { Component } from 'react';
+import { BrowserRouter, Link, Switch, Route } from 'react-router-dom';
+import Home from './Home';
+import Post from './Post';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
$ create-react-app static-react
@astrotim
astrotim / Home.js
Created December 22, 2017 05:09
stub out a new page
// Home.js
import React from 'react';
class Home extends React.Component {
render() {
return <p>Home</p>;
}
}
export default Home;
@astrotim
astrotim / display-grid.sass
Created August 23, 2017 06:27
CSS Grid Mixin
@mixin display-grid {
// single column by default at XS size
@include screen-from($bp-sm-min) {
display: grid;
@include grid-not-supported {
display: flex;
flex-wrap: wrap;
};
@astrotim
astrotim / grid-not-supported.sass
Last active August 23, 2017 06:25
CSS Grid feature detection
@mixin grid-not-supported {
// fallback with native feature detection
@supports not (display: grid) {
@content;
}
// fallback with Modernizr feature detection (IE)
.no-supports & {
@content;
}
@astrotim
astrotim / client.js
Created July 25, 2017 04:21
The application file used by the development Webpack build
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
const root = document.getElementById('root');
ReactDOM.render(<BrowserRouter><App /></BrowserRouter>, root);
@astrotim
astrotim / index.js
Created July 25, 2017 04:20
The application file used by the Webpack production build
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { StaticRouter as Router } from 'react-router-dom';
import App from './App';
import HTML from './HTML';
// static site generator
export default function render(locals, callback) {
const context = {};
@astrotim
astrotim / webpack.prod.config.js
Created July 25, 2017 04:17
Builds site as static files using StaticSiteGeneratorPlugin
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
module.exports = {
entry: [path.resolve(__dirname, 'src')],
output: {
@astrotim
astrotim / webpack.dev.config.js
Created July 25, 2017 04:16
Builds site as client side app and runs with Webpack dev server
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
bundle: path.resolve(__dirname, 'src', 'client.js'),
scripts: path.resolve(__dirname, 'src', 'scripts.js')
},