This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Private property, cannot from the importing file | |
let bar = 'baz' | |
export default class Foo { | |
constructor () { | |
console.log(bar) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default Head extends React.Component { | |
componentWillMount () { | |
ga.push(location.pathname) // This probably isn't quite right, but you get the idea. | |
} | |
render () { | |
<div> | |
<script dangerouslySetInnerHTML={{__html: 'GA Snippet'}} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Component imports | |
import i18next from './i18next' | |
export default class extends React.Component { | |
constructor (props) { | |
super(props) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/******************************************************************************\ | |
Module imports | |
\******************************************************************************/ | |
const { URL } = require('url') | |
const cookie = require('koa-cookie') | |
const next = require('next') | |
const path = require('path') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Module imports | |
import { bindActionCreators } from 'redux' | |
import { | |
connect, | |
Provider, | |
} from 'react-redux' | |
import React from 'react' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Module imports | |
import React from 'react' | |
import { bindActionCreators } from 'redux' | |
import { Provider } from 'react-redux' | |
import withRedux from 'next-redux-wrapper' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NextHead from 'next/head' | |
import React from 'react' | |
import ReactGA from 'react-ga' | |
import Router from 'next/router' | |
/*****************************************************************************\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function etag(options) { | |
return function etag(ctx, next) { | |
return next() | |
// `getResponseEntity` checks to see if the response has a body, and | |
// stringifies it depending on what kind of body it has (JSON, HTML, | |
// image, etc) | |
.then(() => getResponseEntity(ctx)) | |
// `setEtag` calculates the ETag from the response body if it exists, | |
// then sets that ETag as a header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function conditional() { | |
return function conditional(ctx, next) { | |
return next().then(() => { | |
if (ctx.fresh) { | |
ctx.status = 304; | |
ctx.body = null; | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `ctx` is an object that Koa.js passes through its middleware, allowing the | |
// middleware to modify it as they see fit. `ctx.request` and `ctx.response` are | |
// objects that reflect the contents of the HTTP request and response, | |
// respectively | |
var oldEtag = ctx.request.headers['if-none-match'] | |
var newEtag = ctx.response.headers['etag'] | |
ctx.fresh = (oldEtag !== newEtag) |