Skip to content

Instantly share code, notes, and snippets.

View isaachinman's full-sized avatar

Isaac Hinman isaachinman

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@isaachinman
isaachinman / flatten-array.js
Created April 8, 2019 17:42
Recursively flatten an array of integers
const flattenArray = arr =>
arr.reduce((acc, cur) => {
if (Array.isArray(cur)) {
return acc.concat(flattenArray(cur))
}
return acc.concat(cur)
}, [])
{
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
}
}
import React from 'react'
import { i18n, withNamespaces } from '../i18n'
class Homepage extends React.Component {
static async getInitialProps() {
return {
namespacesRequired: ['common'],
}
}
const express = require('express')
const next = require('next')
const nextI18NextMiddleware = require('next-i18next/middleware')
const nextI18next = require('./i18n')
const port = process.env.PORT || 3000
const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = app.getRequestHandler();
import React from 'react'
import App, { Container } from 'next/app'
import { appWithTranslation } from '../i18n'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
return (
<Container>
<Component {...pageProps} />
const NextI18Next = require('next-i18next/dist/commonjs')
module.exports = new NextI18Next({
defaultLanguage: 'en',
otherLanguages: ['de']
})
@isaachinman
isaachinman / common.json
Last active March 4, 2019 20:44
German localised content
{
"title": "Ich bin ein Satz auf Deutsch."
}
@isaachinman
isaachinman / common.json
Created March 4, 2019 20:42
English localised content
{
"title": "I am a sentence in English."
}
@isaachinman
isaachinman / package.json
Created March 4, 2019 15:46
next-i18next-demo/package-next-scripts
{
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
}