1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add prettier for examples directory (#5909)

* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
This commit is contained in:
Tim Neutkens 2018-12-17 17:34:32 +01:00 committed by GitHub
parent 6e2cbfaff3
commit 9c4eefcdbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
391 changed files with 3181 additions and 2130 deletions

View file

@ -7,7 +7,9 @@ const ActiveLink = ({ router, children, ...props }) => {
let className = child.props.className || null
if (router.pathname === props.href && props.activeClassName) {
className = `${className !== null ? className : ''} ${props.activeClassName}`.trim()
className = `${className !== null ? className : ''} ${
props.activeClassName
}`.trim()
}
delete props.activeClassName

View file

@ -1,3 +1 @@
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -1,5 +1 @@
export default () => (
<div>
This is the contact page.
</div>
)
export default () => <div>This is the contact page.</div>

View file

@ -21,7 +21,9 @@ export default class Index extends React.Component {
<h1>Home Page</h1>
<p>Welcome, {name}</p>
<div>
<Link href='/about'><a>About Page</a></Link>
<Link href='/about'>
<a>About Page</a>
</Link>
</div>
</div>
)

View file

@ -1,3 +1 @@
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -1,3 +1 @@
export default () => (
<div>About 2</div>
)
export default () => <div>About 2</div>

View file

@ -1,3 +1 @@
export default () => (
<div>Hello Day</div>
)
export default () => <div>Hello Day</div>

View file

@ -1,4 +1,9 @@
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about'>
<a>About</a>
</Link>
</div>
)

View file

@ -7,15 +7,13 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
handle(req, res, parsedUrl)
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
handle(req, res, parsedUrl)
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -1,5 +1,5 @@
'use strict'
const {Action, api} = require('actionhero')
const { Action, api } = require('actionhero')
module.exports = class CreateChatRoom extends Action {
constructor () {

View file

@ -3,7 +3,7 @@
const path = require('path')
exports['default'] = {
general: (api) => {
general: api => {
const packageJSON = require(api.projectRoot + path.sep + 'package.json')
return {
@ -46,16 +46,16 @@ exports['default'] = {
cliIncludeInternal: true,
// configuration for your actionhero project structure
paths: {
'action': [path.join(__dirname, '/../actions')],
'task': [path.join(__dirname, '/../tasks')],
'public': [path.join(__dirname, '/../static')],
'pid': [path.join(__dirname, '/../pids')],
'log': [path.join(__dirname, '/../log')],
'server': [path.join(__dirname, '/../servers')],
'cli': [path.join(__dirname, '/../bin')],
'initializer': [path.join(__dirname, '/../initializers')],
'plugin': [path.join(__dirname, '/../node_modules')],
'locale': [path.join(__dirname, '/../locales')]
action: [path.join(__dirname, '/../actions')],
task: [path.join(__dirname, '/../tasks')],
public: [path.join(__dirname, '/../static')],
pid: [path.join(__dirname, '/../pids')],
log: [path.join(__dirname, '/../log')],
server: [path.join(__dirname, '/../servers')],
cli: [path.join(__dirname, '/../bin')],
initializer: [path.join(__dirname, '/../initializers')],
plugin: [path.join(__dirname, '/../node_modules')],
locale: [path.join(__dirname, '/../locales')]
},
// hash containing chat rooms you wish to be created at server boot
startingChatRooms: {
@ -67,17 +67,17 @@ exports['default'] = {
}
exports.test = {
general: (api) => {
general: api => {
return {
id: 'test-server-' + process.pid,
serverToken: 'serverToken-' + process.pid,
developmentMode: true,
startingChatRooms: {
'defaultRoom': {},
'otherRoom': {}
defaultRoom: {},
otherRoom: {}
},
paths: {
'locale': [
locale: [
// require('os').tmpdir() + require('path').sep + 'locales',
path.join(__dirname, '/../locales')
]
@ -88,7 +88,7 @@ exports.test = {
}
exports.production = {
general: (api) => {
general: api => {
return {
fileRequestLogLevel: 'debug',
developmentMode: false

View file

@ -2,9 +2,9 @@
// error messages can be strings of objects
exports['default'] = {
errors: (api) => {
errors: api => {
return {
'_toExpand': false,
_toExpand: false,
// ///////////////
// SERIALIZERS //
@ -12,28 +12,28 @@ exports['default'] = {
serializers: {
servers: {
web: (error) => {
web: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
websocket: (error) => {
websocket: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
socket: (error) => {
socket: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
specHelper: (error) => {
specHelper: error => {
if (error.message) {
return 'Error: ' + String(error.message)
} else {
@ -49,38 +49,51 @@ exports['default'] = {
// When a params for an action is invalid
invalidParams: (data, validationErrors) => {
if (validationErrors.length >= 0) { return validationErrors[0] }
if (validationErrors.length >= 0) {
return validationErrors[0]
}
return data.connection.localize('actionhero.errors.invalidParams')
},
// When a required param for an action is not provided
missingParams: (data, missingParams) => {
return data.connection.localize(['actionhero.errors.missingParams', {param: missingParams[0]}])
return data.connection.localize([
'actionhero.errors.missingParams',
{ param: missingParams[0] }
])
},
// user requested an unknown action
unknownAction: (data) => {
unknownAction: data => {
return data.connection.localize('actionhero.errors.unknownAction')
},
// action not useable by this client/server type
unsupportedServerType: (data) => {
return data.connection.localize(['actionhero.errors.unsupportedServerType', {type: data.connection.type}])
unsupportedServerType: data => {
return data.connection.localize([
'actionhero.errors.unsupportedServerType',
{ type: data.connection.type }
])
},
// action failed because server is mid-shutdown
serverShuttingDown: (data) => {
serverShuttingDown: data => {
return data.connection.localize('actionhero.errors.serverShuttingDown')
},
// action failed because this client already has too many pending acitons
// limit defined in api.config.general.simultaneousActions
tooManyPendingActions: (data) => {
return data.connection.localize('actionhero.errors.tooManyPendingActions')
tooManyPendingActions: data => {
return data.connection.localize(
'actionhero.errors.tooManyPendingActions'
)
},
dataLengthTooLarge: (maxLength, receivedLength) => {
return api.i18n.localize(['actionhero.errors.dataLengthTooLarge', {maxLength: maxLength, receivedLength: receivedLength}])
return api.i18n.localize([
'actionhero.errors.dataLengthTooLarge',
{ maxLength: maxLength, receivedLength: receivedLength }
])
},
// ///////////////
@ -89,18 +102,21 @@ exports['default'] = {
// The body message to accompany 404 (file not found) errors regarding flat files
// You may want to load in the contnet of 404.html or similar
fileNotFound: (connection) => {
fileNotFound: connection => {
return connection.localize(['actionhero.errors.fileNotFound'])
},
// user didn't request a file
fileNotProvided: (connection) => {
fileNotProvided: connection => {
return connection.localize('actionhero.errors.fileNotProvided')
},
// something went wrong trying to read the file
fileReadError: (connection, error) => {
return connection.localize(['actionhero.errors.fileReadError', {error: String(error)}])
return connection.localize([
'actionhero.errors.fileReadError',
{ error: String(error) }
])
},
// ///////////////
@ -108,41 +124,54 @@ exports['default'] = {
// ///////////////
verbNotFound: (connection, verb) => {
return connection.localize(['actionhero.errors.verbNotFound', {verb: verb}])
return connection.localize([
'actionhero.errors.verbNotFound',
{ verb: verb }
])
},
verbNotAllowed: (connection, verb) => {
return connection.localize(['actionhero.errors.verbNotAllowed', {verb: verb}])
return connection.localize([
'actionhero.errors.verbNotAllowed',
{ verb: verb }
])
},
connectionRoomAndMessage: (connection) => {
connectionRoomAndMessage: connection => {
return connection.localize('actionhero.errors.connectionRoomAndMessage')
},
connectionNotInRoom: (connection, room) => {
return connection.localize(['actionhero.errors.connectionNotInRoom', {room: room}])
return connection.localize([
'actionhero.errors.connectionNotInRoom',
{ room: room }
])
},
connectionAlreadyInRoom: (connection, room) => {
return connection.localize(['actionhero.errors.connectionAlreadyInRoom', {room: room}])
return connection.localize([
'actionhero.errors.connectionAlreadyInRoom',
{ room: room }
])
},
connectionRoomHasBeenDeleted: (room) => {
return api.i18n.localize('actionhero.errors.connectionRoomHasBeenDeleted')
connectionRoomHasBeenDeleted: room => {
return api.i18n.localize(
'actionhero.errors.connectionRoomHasBeenDeleted'
)
},
connectionRoomNotExist: (room) => {
connectionRoomNotExist: room => {
return api.i18n.localize('actionhero.errors.connectionRoomNotExist')
},
connectionRoomExists: (room) => {
connectionRoomExists: room => {
return api.i18n.localize('actionhero.errors.connectionRoomExists')
},
connectionRoomRequired: (room) => {
connectionRoomRequired: room => {
return api.i18n.localize('actionhero.errors.connectionRoomRequired')
}
}
}
}

View file

@ -1,5 +1,5 @@
exports['default'] = {
i18n: (api) => {
i18n: api => {
return {
// visit https://github.com/mashpie/i18n-node to see all configuration options
// locale path can be configired from within ./config/api.js
@ -28,7 +28,7 @@ exports['default'] = {
}
exports.test = {
i18n: (api) => {
i18n: api => {
return {
updateFiles: true
}

View file

@ -4,16 +4,18 @@ const fs = require('fs')
const cluster = require('cluster')
exports['default'] = {
logger: (api) => {
let logger = {transports: []}
logger: api => {
let logger = { transports: [] }
// console logger
if (cluster.isMaster) {
logger.transports.push(function (api, winston) {
return new (winston.transports.Console)({
return new winston.transports.Console({
colorize: true,
level: 'info',
timestamp: function () { return api.id + ' @ ' + new Date().toISOString() }
timestamp: function () {
return api.id + ' @ ' + new Date().toISOString()
}
})
})
}
@ -26,15 +28,18 @@ exports['default'] = {
fs.mkdirSync(logDirectory)
} catch (e) {
if (e.code !== 'EEXIST') {
throw (new Error('Cannot create log directory @ ' + logDirectory))
throw new Error('Cannot create log directory @ ' + logDirectory)
}
}
}
return new (winston.transports.File)({
filename: api.config.general.paths.log[0] + '/' + api.pids.title + '.log',
return new winston.transports.File({
filename:
api.config.general.paths.log[0] + '/' + api.pids.title + '.log',
level: 'info',
timestamp: function () { return api.id + ' @ ' + new Date().toISOString() }
timestamp: function () {
return api.id + ' @ ' + new Date().toISOString()
}
})
})
@ -52,7 +57,7 @@ exports['default'] = {
}
exports.test = {
logger: (api) => {
logger: api => {
return {
transports: null
}

View file

@ -1,5 +1,5 @@
exports['default'] = {
plugins: (api) => {
plugins: api => {
/*
If you want to use plugins in your application, include them here:

View file

@ -11,15 +11,20 @@ if (process.env.REDIS_URL) {
}
exports['default'] = {
redis: (api) => {
redis: api => {
// konstructor: The redis client constructor method. All redis methods must be promises
// args: The arguments to pass to the constructor
// buildNew: is it `new konstructor()` or just `konstructor()`?
function retryStrategy (times) {
if (times === 1) {
const error = 'Unable to connect to Redis - please check your Redis config!'
if (process.env.NODE_ENV === 'test') { console.error(error) } else { api.log(error, 'error') }
const error =
'Unable to connect to Redis - please check your Redis config!'
if (process.env.NODE_ENV === 'test') {
console.error(error)
} else {
api.log(error, 'error')
}
return 5000
}
return Math.min(times * 50, maxBackoff)
@ -28,20 +33,44 @@ exports['default'] = {
return {
enabled: true,
'_toExpand': false,
_toExpand: false,
client: {
konstructor: require('ioredis'),
args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }],
args: [
{
port: port,
host: host,
password: password,
db: db,
retryStrategy: retryStrategy
}
],
buildNew: true
},
subscriber: {
konstructor: require('ioredis'),
args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }],
args: [
{
port: port,
host: host,
password: password,
db: db,
retryStrategy: retryStrategy
}
],
buildNew: true
},
tasks: {
konstructor: require('ioredis'),
args: [{ port: port, host: host, password: password, db: db, retryStrategy: retryStrategy }],
args: [
{
port: port,
host: host,
password: password,
db: db,
retryStrategy: retryStrategy
}
],
buildNew: true
}
}

View file

@ -1,9 +1,7 @@
exports['default'] = {
routes: (api) => {
routes: api => {
return {
get: [
{ path: '/', matchTrailingPathParts: true, action: 'render' }
]
get: [{ path: '/', matchTrailingPathParts: true, action: 'render' }]
}
}
}

View file

@ -2,9 +2,9 @@
exports['default'] = {
servers: {
socket: (api) => {
socket: api => {
return {
enabled: (process.env.ENABLE_TCP_SERVER !== undefined),
enabled: process.env.ENABLE_TCP_SERVER !== undefined,
// TCP or TLS?
secure: false,
// Passed to tls.createServer if secure=true. Should contain SSL certificates
@ -26,7 +26,7 @@ exports['default'] = {
exports.test = {
servers: {
socket: (api) => {
socket: api => {
return {
enabled: true,
port: 1001 + (process.pid % 64535),

View file

@ -4,7 +4,7 @@ const os = require('os')
exports['default'] = {
servers: {
web: (api) => {
web: api => {
return {
enabled: true,
// HTTP or HTTPS?
@ -13,7 +13,9 @@ exports['default'] = {
serverOptions: {},
// Should we redirect all traffic to the first host in this array if hte request header doesn't match?
// i.e.: [ 'https://www.site.com' ]
allowedRequestHosts: process.env.ALLOWED_HOSTS ? process.env.ALLOWED_HOSTS.split(',') : [],
allowedRequestHosts: process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(',')
: [],
// Port or Socket Path
port: process.env.PORT || 8080,
// Which IP to listen on (use '0.0.0.0' for all; '::' for all on ipv4 and ipv6)
@ -23,7 +25,8 @@ exports['default'] = {
httpHeaders: {
'X-Powered-By': api.config.general.serverName,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE',
'Access-Control-Allow-Methods':
'HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS, TRACE',
'Access-Control-Allow-Headers': 'Content-Type'
},
// Route that actions will be served from; secondary route against this route will be treated as actions,
@ -92,7 +95,7 @@ exports['default'] = {
exports.production = {
servers: {
web: (api) => {
web: api => {
return {
padding: null,
metadataOptions: {
@ -106,7 +109,7 @@ exports.production = {
exports.test = {
servers: {
web: (api) => {
web: api => {
return {
secure: false,
port: process.env.PORT || 1000 + (process.pid % 64535),

View file

@ -4,7 +4,7 @@
exports['default'] = {
servers: {
websocket: (api) => {
websocket: api => {
return {
enabled: true,
// you can pass a FQDN (string) here or 'window.location.origin'
@ -55,7 +55,7 @@ exports['default'] = {
exports['test'] = {
servers: {
websocket: (api) => {
websocket: api => {
return { clientUrl: null }
}
}

View file

@ -1,5 +1,5 @@
exports['default'] = {
tasks: (api) => {
tasks: api => {
return {
// Should this node run a scheduler to promote delayed tasks?
scheduler: false,
@ -52,7 +52,7 @@ exports['default'] = {
}
exports.test = {
tasks: (api) => {
tasks: api => {
return {
timeout: 100,
checkTimeout: 50

View file

@ -1,5 +1,5 @@
'use strict'
const {Initializer, api} = require('actionhero')
const { Initializer, api } = require('actionhero')
const next = require('next')
module.exports = class NextInitializer extends Initializer {
@ -10,18 +10,22 @@ module.exports = class NextInitializer extends Initializer {
async initialize () {
api.next = {
render: async (connection) => {
if (connection.type !== 'web') { throw new Error('Connections for NEXT apps must be of type "web"') }
render: async connection => {
if (connection.type !== 'web') {
throw new Error('Connections for NEXT apps must be of type "web"')
}
const req = connection.rawConnection.req
const res = connection.rawConnection.res
return api.next.handle(req, res)
}
}
api.next.dev = (api.env === 'development')
if (api.next.dev) { api.log('Running next in development mode...') }
api.next.dev = api.env === 'development'
if (api.next.dev) {
api.log('Running next in development mode...')
}
api.next.app = next({dev: api.next.dev})
api.next.app = next({ dev: api.next.dev })
api.next.handle = api.next.app.getRequestHandler()
await api.next.app.prepare()
}

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -3,13 +3,18 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link
href={{pathname: '/posts', query: { id: '2' }}}
as='/posts/2'
>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
<li>
<Link href={{ pathname: '/posts', query: { id: '2' } }} as='/posts/2'>
<a>post #2</a>
</Link>
</li>

View file

@ -6,12 +6,14 @@ export default class extends Component {
}
render () {
return <div>
<h1>My blog post #{this.props.postId}</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
return (
<div>
<h1>My blog post #{this.props.postId}</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
)
}
}

View file

@ -6,28 +6,27 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
const server = express()
app.prepare().then(() => {
const server = express()
server.get('/a', (req, res) => {
return app.render(req, res, '/b', req.query)
})
server.get('/b', (req, res) => {
return app.render(req, res, '/a', req.query)
})
server.get('/posts/:id', (req, res) => {
return app.render(req, res, '/posts', { id: req.params.id })
})
server.get('*', (req, res) => {
return handle(req, res)
})
server.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
server.get('/a', (req, res) => {
return app.render(req, res, '/b', req.query)
})
server.get('/b', (req, res) => {
return app.render(req, res, '/a', req.query)
})
server.get('/posts/:id', (req, res) => {
return app.render(req, res, '/posts', { id: req.params.id })
})
server.get('*', (req, res) => {
return handle(req, res)
})
server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -6,51 +6,47 @@ const dev = process.env.NODE_ENV !== 'production'
fastify.register((fastify, opts, next) => {
const app = Next({ dev })
app.prepare()
app
.prepare()
.then(() => {
if (dev) {
fastify.get('/_next/*', (req, reply) => {
return app.handleRequest(req.req, reply.res)
.then(() => {
reply.sent = true
})
return app.handleRequest(req.req, reply.res).then(() => {
reply.sent = true
})
})
}
fastify.get('/a', (req, reply) => {
return app.render(req.req, reply.res, '/b', req.query)
.then(() => {
reply.sent = true
})
return app.render(req.req, reply.res, '/b', req.query).then(() => {
reply.sent = true
})
})
fastify.get('/b', (req, reply) => {
return app.render(req.req, reply.res, '/a', req.query)
.then(() => {
reply.sent = true
})
return app.render(req.req, reply.res, '/a', req.query).then(() => {
reply.sent = true
})
})
fastify.get('/*', (req, reply) => {
return app.handleRequest(req.req, reply.res)
.then(() => {
reply.sent = true
})
return app.handleRequest(req.req, reply.res).then(() => {
reply.sent = true
})
})
fastify.setNotFoundHandler((request, reply) => {
return app.render404(request.req, reply.res)
.then(() => {
reply.sent = true
})
return app.render404(request.req, reply.res).then(() => {
reply.sent = true
})
})
next()
})
.catch((err) => next(err))
.catch(err => next(err))
})
fastify.listen(port, (err) => {
fastify.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})

View file

@ -13,7 +13,13 @@ const defaultHandlerWrapper = app => async ({ raw: { req, res }, url }) => {
}
const pathWrapper = (app, pathName, opts) => async ({ raw, query, params }) => {
return app.renderToHTML(raw.req, raw.res, pathName, { ...query, ...params }, opts)
return app.renderToHTML(
raw.req,
raw.res,
pathName,
{ ...query, ...params },
opts
)
}
module.exports = { pathWrapper, defaultHandlerWrapper, nextHandlerWrapper }

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -1,6 +1,10 @@
const next = require('next')
const Hapi = require('hapi')
const { pathWrapper, defaultHandlerWrapper, nextHandlerWrapper } = require('./next-wrapper')
const {
pathWrapper,
defaultHandlerWrapper,
nextHandlerWrapper
} = require('./next-wrapper')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
@ -9,38 +13,36 @@ const server = new Hapi.Server({
port
})
app
.prepare()
.then(async () => {
server.route({
method: 'GET',
path: '/a',
handler: pathWrapper(app, '/a')
})
server.route({
method: 'GET',
path: '/b',
handler: pathWrapper(app, '/b')
})
server.route({
method: 'GET',
path: '/_next/{p*}', /* next specific routes */
handler: nextHandlerWrapper(app)
})
server.route({
method: 'GET',
path: '/{p*}', /* catch all route */
handler: defaultHandlerWrapper(app)
})
try {
await server.start()
console.log(`> Ready on http://localhost:${port}`)
} catch (error) {
console.log('Error starting server')
console.log(error)
}
app.prepare().then(async () => {
server.route({
method: 'GET',
path: '/a',
handler: pathWrapper(app, '/a')
})
server.route({
method: 'GET',
path: '/b',
handler: pathWrapper(app, '/b')
})
server.route({
method: 'GET',
path: '/_next/{p*}' /* next specific routes */,
handler: nextHandlerWrapper(app)
})
server.route({
method: 'GET',
path: '/{p*}' /* catch all route */,
handler: defaultHandlerWrapper(app)
})
try {
await server.start()
console.log(`> Ready on http://localhost:${port}`)
} catch (error) {
console.log('Error starting server')
console.log(error)
}
})

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -7,33 +7,32 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
const server = new Koa()
const router = new Router()
app.prepare().then(() => {
const server = new Koa()
const router = new Router()
router.get('/a', async ctx => {
await app.render(ctx.req, ctx.res, '/b', ctx.query)
ctx.respond = false
})
router.get('/b', async ctx => {
await app.render(ctx.req, ctx.res, '/a', ctx.query)
ctx.respond = false
})
router.get('*', async ctx => {
await handle(ctx.req, ctx.res)
ctx.respond = false
})
server.use(async (ctx, next) => {
ctx.res.statusCode = 200
await next()
})
server.use(router.routes())
server.listen(port, () => {
console.log(`> Ready on http://localhost:${port}`)
})
router.get('/a', async ctx => {
await app.render(ctx.req, ctx.res, '/b', ctx.query)
ctx.respond = false
})
router.get('/b', async ctx => {
await app.render(ctx.req, ctx.res, '/a', ctx.query)
ctx.respond = false
})
router.get('*', async ctx => {
await handle(ctx.req, ctx.res)
ctx.respond = false
})
server.use(async (ctx, next) => {
ctx.res.statusCode = 200
await next()
})
server.use(router.routes())
server.listen(port, () => {
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -7,22 +7,20 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
if (pathname === '/a') {
app.render(req, res, '/b', query)
} else if (pathname === '/b') {
app.render(req, res, '/a', query)
} else {
handle(req, res, parsedUrl)
}
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
if (pathname === '/a') {
app.render(req, res, '/b', query)
} else if (pathname === '/b') {
app.render(req, res, '/a', query)
} else {
handle(req, res, parsedUrl)
}
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -3,7 +3,15 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/b' as='/a'><a>a</a></Link></li>
<li><Link href='/a' as='/b'><a>b</a></Link></li>
<li>
<Link href='/b' as='/a'>
<a>a</a>
</Link>
</li>
<li>
<Link href='/a' as='/b'>
<a>b</a>
</Link>
</li>
</ul>
)

View file

@ -7,22 +7,20 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname, query } = parsedUrl
if (pathname === '/a') {
app.render(req, res, '/b', query)
} else if (pathname === '/b') {
app.render(req, res, '/a', query)
} else {
handle(req, res, parsedUrl)
}
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
if (pathname === '/a') {
app.render(req, res, '/b', query)
} else if (pathname === '/b') {
app.render(req, res, '/a', query)
} else {
handle(req, res, parsedUrl)
}
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -14,7 +14,9 @@ export default class Index extends React.Component {
return (
<div>
<p>Next.js has {this.props.stars} </p>
<Link prefetch href='/preact'><a>How about preact?</a></Link>
<Link prefetch href='/preact'>
<a>How about preact?</a>
</Link>
</div>
)
}

View file

@ -14,7 +14,9 @@ export default class Preact extends React.Component {
return (
<div>
<p>Preact has {this.props.stars} </p>
<Link prefetch href='/'><a>I bet next has more stars (?)</a></Link>
<Link prefetch href='/'>
<a>I bet next has more stars (?)</a>
</Link>
</div>
)
}

View file

@ -1,5 +1,5 @@
import { INPUT_VALUE } from '../constants'
export const inputChange = (title, name, val) => dispatch => {
return dispatch({type: INPUT_VALUE, title, name, val})
return dispatch({ type: INPUT_VALUE, title, name, val })
}

View file

@ -1,4 +1,4 @@
import React, {Component} from 'react'
import React, { Component } from 'react'
import { Col, Row } from 'react-bootstrap'
import { connect } from 'react-redux'
@ -9,7 +9,7 @@ class DisplayForm extends Component {
<div>
<Row>
<Col lg={8} lgOffset={2}>
<pre>{JSON.stringify(state, null, 2) }</pre>
<pre>{JSON.stringify(state, null, 2)}</pre>
</Col>
</Row>
</div>

View file

@ -6,7 +6,7 @@ const Header = () => {
<Row style={{ marginTop: '10px' }}>
<Col lg={8} lgOffset={2}>
<Jumbotron style={{ borderRadius: '15px' }}>
<h1 style={{textAlign: 'center'}}>Form Handler</h1>
<h1 style={{ textAlign: 'center' }}>Form Handler</h1>
</Jumbotron>
</Col>
</Row>

View file

@ -16,7 +16,12 @@ const UserForm = () => {
<Input controlLabel='Email' type='email' title='user' name='email' />
</Col>
<Col lg={8} lgOffset={4}>
<Input controlLabel='Password' type='password' title='user' name='password' />
<Input
controlLabel='Password'
type='password'
title='user'
name='password'
/>
</Col>
</Row>
</div>

View file

@ -1,4 +1,4 @@
import React, {Component} from 'react'
import React, { Component } from 'react'
import Head from 'next/head'
import { Col, Row } from 'react-bootstrap'
@ -14,7 +14,10 @@ class Main extends Component {
<div>
<Head>
<title>Form Handler</title>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css' />
<link
rel='stylesheet'
href='https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css'
/>
</Head>
<Header />
<DisplayForm />

View file

@ -1,4 +1,4 @@
import React, {Component} from 'react'
import React, { Component } from 'react'
import { FormGroup, ControlLabel, FormControl } from 'react-bootstrap'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
@ -6,7 +6,7 @@ import { bindActionCreators } from 'redux'
import { inputChange } from '../actions'
class Input extends Component {
inputChange = (e) => {
inputChange = e => {
const { inputChange, title, name } = this.props
inputChange(title, name, e.target.value)
}
@ -35,4 +35,7 @@ const mapDispatchToProps = dispatch => {
}
}
export default connect(null, mapDispatchToProps)(Input)
export default connect(
null,
mapDispatchToProps
)(Input)

View file

@ -3,11 +3,9 @@ import { INPUT_VALUE } from '../constants'
export default (state = {}, action) => {
switch (action.type) {
case INPUT_VALUE:
return { ...state,
[action.title]:
{ ...state[action.title],
[action.name]: action.val
}
return {
...state,
[action.title]: { ...state[action.title], [action.name]: action.val }
}
default:
return state

View file

@ -5,7 +5,8 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
app
.prepare()
.then(() => {
const server = express()
@ -17,12 +18,12 @@ app.prepare()
return handle(req, res)
})
server.listen(3000, (err) => {
server.listen(3000, err => {
if (err) throw err
console.log('> Ready on http://localhost:3000')
})
})
.catch((ex) => {
.catch(ex => {
console.error(ex.stack)
process.exit(1)
})

View file

@ -1,10 +1,6 @@
const env = require('./env-config')
module.exports = {
'presets': [
'next/babel'
],
'plugins': [
['transform-define', env]
]
presets: ['next/babel'],
plugins: [['transform-define', env]]
}

View file

@ -2,6 +2,11 @@ import Link from 'next/link'
export default () => (
<div>
<div>About us</div>
<div>Back to <Link href='/' as={process.env.BACKEND_URL + '/'}><a>Home</a></Link></div>
<div>
Back to{' '}
<Link href='/' as={process.env.BACKEND_URL + '/'}>
<a>Home</a>
</Link>
</div>
</div>
)

View file

@ -1,4 +1,9 @@
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about' as={process.env.BACKEND_URL + '/about'}><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about' as={process.env.BACKEND_URL + '/about'}>
<a>About</a>
</Link>
</div>
)

View file

@ -1,3 +1 @@
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -1,3 +1 @@
export default () => (
<div>Hello Day</div>
)
export default () => <div>Hello Day</div>

View file

@ -1,4 +1,9 @@
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about'>
<a>About</a>
</Link>
</div>
)

View file

@ -4,22 +4,28 @@ import Head from 'next/head'
export default ({ children, title = 'This is the default title' }) => (
<div>
<Head>
<title>{ title }</title>
<title>{title}</title>
<meta charSet='utf-8' />
<meta name='viewport' content='initial-scale=1.0, width=device-width' />
</Head>
<header>
<nav>
<Link href='/'><a>Home</a></Link> |
<Link href='/about'><a>About</a></Link> |
<Link href='/contact'><a>Contact</a></Link>
<Link href='/'>
<a>Home</a>
</Link>{' '}
|
<Link href='/about'>
<a>About</a>
</Link>{' '}
|
<Link href='/contact'>
<a>Contact</a>
</Link>
</nav>
</header>
{ children }
{children}
<footer>
{'I`m here to stay'}
</footer>
<footer>{'I`m here to stay'}</footer>
</div>
)

View file

@ -1,7 +1,7 @@
export default ({ title, children }) => (
<div className='main'>
<h1>{ title }</h1>
{ children }
<h1>{title}</h1>
{children}
<style jsx>{`
.main {
font: 15px Helvetica, Arial;

View file

@ -37,7 +37,7 @@ export default () => (
}
hr::before {
content: "***";
content: '***';
color: #ccc;
}
`}</style>

View file

@ -5,8 +5,9 @@ export default dynamic({
BarChart: import('recharts').then(({ BarChart }) => BarChart),
Bar: import('recharts').then(({ Bar }) => Bar)
}),
render: (props, { BarChart, Bar }) =>
render: (props, { BarChart, Bar }) => (
<BarChart width={props.width} height={props.height} data={props.data}>
<Bar dataKey='uv' fill='#8884d8' />
</BarChart>
)
})

View file

@ -5,8 +5,9 @@ export default dynamic({
LineChart: import('recharts').then(({ LineChart }) => LineChart),
Line: import('recharts').then(({ Line }) => Line)
}),
render: (props, { LineChart, Line }) =>
render: (props, { LineChart, Line }) => (
<LineChart width={props.width} height={props.height} data={props.data}>
<Line type='monotone' dataKey='uv' stroke='#8884d8' />
</LineChart>
)
})

View file

@ -2,13 +2,13 @@ import React from 'react'
import BarChart from '../components/BarChart'
const data = [
{name: 'Page A', uv: 4000, pv: 2400, amt: 2400},
{name: 'Page B', uv: 3000, pv: 1398, amt: 2210},
{name: 'Page C', uv: 2000, pv: 9800, amt: 2290},
{name: 'Page D', uv: 2780, pv: 3908, amt: 2000},
{name: 'Page E', uv: 1890, pv: 4800, amt: 2181},
{name: 'Page F', uv: 2390, pv: 3800, amt: 2500},
{name: 'Page G', uv: 3490, pv: 4300, amt: 2100}
{ name: 'Page A', uv: 4000, pv: 2400, amt: 2400 },
{ name: 'Page B', uv: 3000, pv: 1398, amt: 2210 },
{ name: 'Page C', uv: 2000, pv: 9800, amt: 2290 },
{ name: 'Page D', uv: 2780, pv: 3908, amt: 2000 },
{ name: 'Page E', uv: 1890, pv: 4800, amt: 2181 },
{ name: 'Page F', uv: 2390, pv: 3800, amt: 2500 },
{ name: 'Page G', uv: 3490, pv: 4300, amt: 2100 }
]
const Chart = () => (

View file

@ -3,13 +3,13 @@ import Link from 'next/link'
import LineChart from '../components/LineChart'
const data = [
{name: 'Page A', uv: 1000, pv: 2400, amt: 2400},
{name: 'Page B', uv: 3000, pv: 1398, amt: 2210},
{name: 'Page C', uv: 2000, pv: 9800, amt: 2290},
{name: 'Page D', uv: 2780, pv: 3908, amt: 2000},
{name: 'Page E', uv: 1890, pv: 4800, amt: 2181},
{name: 'Page F', uv: 2390, pv: 3800, amt: 2500},
{name: 'Page G', uv: 3490, pv: 4300, amt: 2100}
{ name: 'Page A', uv: 1000, pv: 2400, amt: 2400 },
{ name: 'Page B', uv: 3000, pv: 1398, amt: 2210 },
{ name: 'Page C', uv: 2000, pv: 9800, amt: 2290 },
{ name: 'Page D', uv: 2780, pv: 3908, amt: 2000 },
{ name: 'Page E', uv: 1890, pv: 4800, amt: 2181 },
{ name: 'Page F', uv: 2390, pv: 3800, amt: 2500 },
{ name: 'Page G', uv: 3490, pv: 4300, amt: 2100 }
]
const Index = () => (

View file

@ -6,12 +6,14 @@ export default class extends React.Component {
}
render () {
return <div>
<h1>My {this.props.id} blog post</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
return (
<div>
<h1>My {this.props.id} blog post</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
)
}
}

View file

@ -2,8 +2,20 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/blog?id=first' as='/blog/first'><a>My first blog post</a></Link></li>
<li><Link href='/blog?id=second' as='/blog/second'><a>My second blog post</a></Link></li>
<li><Link href='/blog?id=last' as='/blog/last'><a>My last blog post</a></Link></li>
<li>
<Link href='/blog?id=first' as='/blog/first'>
<a>My first blog post</a>
</Link>
</li>
<li>
<Link href='/blog?id=second' as='/blog/second'>
<a>My second blog post</a>
</Link>
</li>
<li>
<Link href='/blog?id=last' as='/blog/last'>
<a>My last blog post</a>
</Link>
</li>
</ul>
)

View file

@ -10,22 +10,20 @@ const handle = app.getRequestHandler()
const route = pathMatch()
const match = route('/blog/:id')
app.prepare()
.then(() => {
createServer((req, res) => {
const { pathname, query } = parse(req.url, true)
const params = match(pathname)
if (params === false) {
handle(req, res)
return
}
// assigning `query` into the params means that we still
// get the query string passed to our application
// i.e. /blog/foo?show-comments=true
app.render(req, res, '/blog', Object.assign(params, query))
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const { pathname, query } = parse(req.url, true)
const params = match(pathname)
if (params === false) {
handle(req, res)
return
}
// assigning `query` into the params means that we still
// get the query string passed to our application
// i.e. /blog/foo?show-comments=true
app.render(req, res, '/blog', Object.assign(params, query))
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -3,6 +3,10 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/item'><a>View Item</a></Link></li>
<li>
<Link href='/item'>
<a>View Item</a>
</Link>
</li>
</ul>
)

View file

@ -1,4 +1,4 @@
import {Component} from 'react'
import { Component } from 'react'
import Link from 'next/link'
import fetch from 'isomorphic-unfetch'
@ -15,7 +15,9 @@ export default class extends Component {
return { item: query.itemData }
} else {
// On the client, we should fetch the data remotely
const res = await fetch('/_data/item', {headers: {'Accept': 'application/json'}})
const res = await fetch('/_data/item', {
headers: { Accept: 'application/json' }
})
const json = await res.json()
return { item: json }
}
@ -24,9 +26,15 @@ export default class extends Component {
render () {
return (
<div className='item'>
<div><Link href='/'><a>Back Home</a></Link></div>
<div>
<Link href='/'>
<a>Back Home</a>
</Link>
</div>
<h1>{this.props.item.title}</h1>
<h2>{this.props.item.subtitle} - {this.props.item.seller}</h2>
<h2>
{this.props.item.subtitle} - {this.props.item.seller}
</h2>
</div>
)
}

View file

@ -32,7 +32,7 @@ app.prepare().then(() => {
return handle(req, res)
})
server.listen(3000, (err) => {
server.listen(3000, err => {
if (err) throw err
console.log('> Ready on http://localhost:3000')
})

View file

@ -5,9 +5,7 @@ import Loading from '../components/Loading'
export default () => (
<main>
<section>
<h1>
This section is server-side rendered.
</h1>
<h1>This section is server-side rendered.</h1>
</section>
<NoSSR onSSR={<Loading />}>

View file

@ -1,7 +1,13 @@
export default () => (
<ul>
<li><a href='/robots.txt'>/robots.txt</a></li>
<li><a href='/sitemap.xml'>/sitemap.xml</a></li>
<li><a href='/favicon.ico'>/favicon.ico</a></li>
<li>
<a href='/robots.txt'>/robots.txt</a>
</li>
<li>
<a href='/sitemap.xml'>/sitemap.xml</a>
</li>
<li>
<a href='/favicon.ico'>/favicon.ico</a>
</li>
</ul>
)

View file

@ -8,24 +8,18 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const rootStaticFiles = [
'/robots.txt',
'/sitemap.xml',
'/favicon.ico'
]
if (rootStaticFiles.indexOf(parsedUrl.pathname) > -1) {
const path = join(__dirname, 'static', parsedUrl.pathname)
app.serveStatic(req, res, path)
} else {
handle(req, res, parsedUrl)
}
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const rootStaticFiles = ['/robots.txt', '/sitemap.xml', '/favicon.ico']
if (rootStaticFiles.indexOf(parsedUrl.pathname) > -1) {
const path = join(__dirname, 'static', parsedUrl.pathname)
app.serveStatic(req, res, path)
} else {
handle(req, res, parsedUrl)
}
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -3,11 +3,11 @@ import Link from 'next/link'
export default () => (
<div>
<Link href='/'>
<a style={styles.a} >Home</a>
<a style={styles.a}>Home</a>
</Link>
<Link href='/about'>
<a style={styles.a} >About</a>
<a style={styles.a}>About</a>
</Link>
</div>
)

View file

@ -6,12 +6,14 @@ export default class extends React.Component {
}
render () {
return <div>
<h1>My {this.props.id} blog post</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
return (
<div>
<h1>My {this.props.id} blog post</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
)
}
}

View file

@ -2,8 +2,20 @@ import Link from 'next/link'
export default () => (
<ul>
<li><Link href='/blog?id=first' as='/blog/first'><a>My first blog post</a></Link></li>
<li><Link href='/blog?id=second' as='/blog/second'><a>My second blog post</a></Link></li>
<li><Link href='/blog?id=last' as='/blog/last'><a>My last blog post</a></Link></li>
<li>
<Link href='/blog?id=first' as='/blog/first'>
<a>My first blog post</a>
</Link>
</li>
<li>
<Link href='/blog?id=second' as='/blog/second'>
<a>My second blog post</a>
</Link>
</li>
<li>
<Link href='/blog?id=last' as='/blog/last'>
<a>My last blog post</a>
</Link>
</li>
</ul>
)

View file

@ -16,30 +16,29 @@ const ssrCache = new LRUCache({
maxAge: 1000 * 60 * 60 // 1hour
})
app.prepare()
.then(() => {
const server = express()
app.prepare().then(() => {
const server = express()
// Use the `renderAndCache` utility defined below to serve pages
server.get('/', (req, res) => {
renderAndCache(req, res, '/')
})
server.get('/blog/:id', (req, res) => {
const queryParams = { id: req.params.id }
renderAndCache(req, res, '/blog', queryParams)
})
server.get('*', (req, res) => {
return handle(req, res)
})
server.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
// Use the `renderAndCache` utility defined below to serve pages
server.get('/', (req, res) => {
renderAndCache(req, res, '/')
})
server.get('/blog/:id', (req, res) => {
const queryParams = { id: req.params.id }
renderAndCache(req, res, '/blog', queryParams)
})
server.get('*', (req, res) => {
return handle(req, res)
})
server.listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
/*
* NB: make sure to modify this to take into account anything that should trigger
* an immediate page change (e.g a locale stored in req.session)

View file

@ -7,7 +7,7 @@ module.exports = {
}
config.resolve.alias = {
'react': 'inferno-compat',
react: 'inferno-compat',
'react-dom': 'inferno-compat'
}
return config

View file

@ -1,5 +1,3 @@
import React from 'react'
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -2,5 +2,10 @@ import React from 'react'
import Link from 'next/link'
export default () => (
<div>Hello World. <Link prefetch href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link prefetch href='/about'>
<a>About</a>
</Link>
</div>
)

View file

@ -17,14 +17,12 @@ const next = require('next')
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -1,5 +1,3 @@
import React from 'react'
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -2,5 +2,10 @@ import React from 'react'
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about'>
<a>About</a>
</Link>
</div>
)

View file

@ -16,14 +16,12 @@ const next = require('next')
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -1,5 +1,3 @@
import React from 'react'
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>

View file

@ -2,5 +2,10 @@ import React from 'react'
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about'>
<a>About</a>
</Link>
</div>
)

View file

@ -10,14 +10,12 @@ const next = require('next')
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})

View file

@ -13,7 +13,7 @@ export default () => (
// and use it manually
function onClickHandler (href) {
return (e) => {
return e => {
e.preventDefault()
Router.push(href)
}

View file

@ -1,4 +1,4 @@
import {Component} from 'react'
import { Component } from 'react'
import Header from '../components/Header'
import Router from 'next/router'

View file

@ -10,7 +10,7 @@ const ActiveLink = ({ children, router, href }) => {
color: router.pathname === href ? 'red' : 'black'
}
const handleClick = (e) => {
const handleClick = e => {
e.preventDefault()
router.push(href)
}

View file

@ -1,4 +1,4 @@
import {Component} from 'react'
import { Component } from 'react'
import Header from '../components/Header'
import Router from 'next/router'

View file

@ -10,7 +10,7 @@ import {
} from 'react-instantsearch/dom'
import { InstantSearch } from './instantsearch'
const HitComponent = ({ hit }) =>
const HitComponent = ({ hit }) => (
<div className='hit'>
<div>
<div className='hit-picture'>
@ -20,12 +20,8 @@ const HitComponent = ({ hit }) =>
<div className='hit-content'>
<div>
<Highlight attributeName='name' hit={hit} />
<span>
{' '}- ${hit.price}
</span>
<span>
{' '}- {hit.rating} stars
</span>
<span> - ${hit.price}</span>
<span> - {hit.rating} stars</span>
</div>
<div className='hit-type'>
<Highlight attributeName='type' hit={hit} />
@ -35,6 +31,7 @@ const HitComponent = ({ hit }) =>
</div>
</div>
</div>
)
HitComponent.propTypes = {
hit: PropTypes.object
@ -45,7 +42,7 @@ export default class extends React.Component {
searchState: PropTypes.object,
resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
onSearchStateChange: PropTypes.func
};
}
render () {
return (

View file

@ -6,7 +6,7 @@ const defaultDescription = ''
const defaultOGURL = ''
const defaultOGImage = ''
export const Head = props =>
export const Head = props => (
<NextHead>
<meta charSet='UTF-8' />
<title>{props.title || ''}</title>
@ -37,6 +37,7 @@ export const Head = props =>
/>
<link rel='stylesheet' href='../static/instantsearch.css' />
</NextHead>
)
Head.propTypes = {
title: string,

View file

@ -13,7 +13,7 @@ export default class extends React.Component {
static propTypes = {
resultsState: PropTypes.object,
searchState: PropTypes.object
};
}
constructor (props) {
super(props)
@ -42,7 +42,7 @@ export default class extends React.Component {
})
}, updateAfter)
this.setState({ searchState })
};
}
componentDidMount () {
this.setState({ searchState: qs.parse(window.location.search.slice(1)) })

View file

@ -1,5 +1 @@
export default ({ author }) => (
<div className='byline'>
By {author}
</div>
)
export default ({ author }) => <div className='byline'>By {author}</div>

View file

@ -8,8 +8,14 @@ export default class MyDocument extends Document {
<Head>
<link rel='canonical' href='/' />
<meta name='viewport' content='width=device-width,minimum-scale=1' />
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto' />
<style amp-boilerplate=''>{`body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}`}</style><noscript><style amp-boilerplate=''>{`body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}`}</style></noscript>
<link
rel='stylesheet'
href='https://fonts.googleapis.com/css?family=Roboto'
/>
<style amp-boilerplate=''>{`body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}`}</style>
<noscript>
<style amp-boilerplate=''>{`body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}`}</style>
</noscript>
<style amp-custom=''>{`body {font-family: Roboto, sans-serif; padding: 30px; color: #444;} h1 {margin-bottom: 5px;} .byline { color: #aaa; margin-bottom: 25px; } p {font-size: 18px; line-height: 30px; margin-top: 30px;} .caption {color: #ccc; margin-top: 0; font-size: 14px; text-align: center;}`}</style>
<script async src='https://cdn.ampproject.org/v0.js' />
</Head>

View file

@ -8,12 +8,76 @@ export default () => (
</Head>
<h1>The Dog</h1>
<Byline author='Meow Meow Fuzzyface' />
<amp-img src='/static/dog.jpg' width='470' height='350' layout='responsive' alt='Woof' />
<amp-img
src='/static/dog.jpg'
width='470'
height='350'
layout='responsive'
alt='Woof'
/>
<p className='caption'>Woooooooooooof</p>
<p>Wafer donut candy soufflé lemon drops icing. Marzipan gummi bears pie danish lollipop pudding powder gummi bears sweet. Pie sweet roll sweet roll topping chocolate bar dragée pudding chocolate cake. Croissant sweet chocolate bar cheesecake candy canes. Tootsie roll icing macaroon bonbon cupcake apple pie candy canes biscuit candy canes. Jujubes jelly liquorice toffee gingerbread. Candy tootsie roll macaroon chocolate bar icing sugar plum pie. Icing gummies chocolate bar chocolate marzipan bonbon cookie chocolate tart. Caramels danish halvah croissant. Cheesecake cookie tootsie roll ice cream. Powder dessert carrot cake muffin tiramisu lemon drops liquorice topping brownie. Soufflé chocolate cake croissant cupcake jelly.</p>
<p>Muffin gummies dessert cheesecake candy canes. Candy canes danish cotton candy tart dessert powder bear claw marshmallow. Muffin chocolate marshmallow danish. Chocolate bar biscuit cake tiramisu. Topping sweet brownie jujubes powder marzipan. Croissant wafer bonbon chupa chups cake cake marzipan caramels jujubes. Cupcake cheesecake sweet roll marshmallow lollipop danish jujubes jelly icing. Apple pie chupa chups lollipop jelly-o cheesecake jelly beans cake dessert. Tootsie roll tootsie roll bonbon pastry croissant gummi bears cake cake. Fruitcake sugar plum halvah gingerbread cookie pastry chupa chups wafer lemon drops. Marshmallow liquorice oat cake lollipop. Lemon drops oat cake halvah liquorice danish powder cupcake soufflé. Cake tart topping jelly-o tart sugar plum. Chocolate bar cookie wafer tootsie roll candy cotton candy toffee pie donut.</p>
<p>Ice cream lollipop marshmallow tiramisu jujubes croissant. Bear claw lemon drops marzipan candy bonbon cupcake powder. Candy canes cheesecake bear claw pastry cake donut jujubes. Icing tart jelly-o soufflé bonbon apple pie. Cheesecake pie chupa chups toffee powder. Bonbon lemon drops carrot cake pudding candy halvah cheesecake lollipop cupcake. Pudding marshmallow fruitcake. Gummi bears bonbon chupa chups lemon drops. Wafer dessert gummies gummi bears biscuit donut tiramisu gummi bears brownie. Tootsie roll liquorice bonbon cookie. Sesame snaps chocolate bar cake croissant chupa chups cheesecake gingerbread tiramisu jelly. Cheesecake ice cream muffin lollipop gummies. Sesame snaps jelly beans sweet bear claw tart.</p>
<p>Sweet topping chupa chups chocolate cake jelly-o liquorice danish. Pastry jelly beans apple pie dessert pastry lemon drops marzipan gummies. Jelly beans macaroon bear claw cotton candy. Toffee sweet lollipop toffee oat cake. Jelly-o oat cake fruitcake chocolate bar sweet. Lemon drops gummies chocolate cake lollipop bear claw croissant danish icing. Chocolate bar donut brownie chocolate cake lemon drops chocolate bar. Cake fruitcake pudding chocolate apple pie. Brownie tiramisu chocolate macaroon lemon drops wafer soufflé jujubes icing. Cheesecake tiramisu cake macaroon tart lollipop donut. Gummi bears dragée pudding bear claw. Muffin cake cupcake candy canes. Soufflé candy canes biscuit. Macaroon gummies danish.</p>
<p>Cupcake cupcake tart. Cotton candy danish candy canes oat cake ice cream candy canes powder wafer. Chocolate sesame snaps oat cake dragée cheesecake. Sesame snaps marshmallow topping liquorice cookie marshmallow. Liquorice pudding chocolate bar. Cake powder brownie fruitcake. Carrot cake dessert marzipan sugar plum cupcake cheesecake pastry. Apple pie macaroon ice cream fruitcake apple pie cookie. Tootsie roll ice cream oat cake cheesecake donut cheesecake bear claw. Sesame snaps marzipan jelly beans chocolate tootsie roll. Chocolate bar donut dragée ice cream biscuit. Pie candy canes muffin candy canes ice cream tiramisu.</p>
<p>
Wafer donut candy soufflé lemon drops icing. Marzipan gummi bears pie
danish lollipop pudding powder gummi bears sweet. Pie sweet roll sweet
roll topping chocolate bar dragée pudding chocolate cake. Croissant sweet
chocolate bar cheesecake candy canes. Tootsie roll icing macaroon bonbon
cupcake apple pie candy canes biscuit candy canes. Jujubes jelly liquorice
toffee gingerbread. Candy tootsie roll macaroon chocolate bar icing sugar
plum pie. Icing gummies chocolate bar chocolate marzipan bonbon cookie
chocolate tart. Caramels danish halvah croissant. Cheesecake cookie
tootsie roll ice cream. Powder dessert carrot cake muffin tiramisu lemon
drops liquorice topping brownie. Soufflé chocolate cake croissant cupcake
jelly.
</p>
<p>
Muffin gummies dessert cheesecake candy canes. Candy canes danish cotton
candy tart dessert powder bear claw marshmallow. Muffin chocolate
marshmallow danish. Chocolate bar biscuit cake tiramisu. Topping sweet
brownie jujubes powder marzipan. Croissant wafer bonbon chupa chups cake
cake marzipan caramels jujubes. Cupcake cheesecake sweet roll marshmallow
lollipop danish jujubes jelly icing. Apple pie chupa chups lollipop
jelly-o cheesecake jelly beans cake dessert. Tootsie roll tootsie roll
bonbon pastry croissant gummi bears cake cake. Fruitcake sugar plum halvah
gingerbread cookie pastry chupa chups wafer lemon drops. Marshmallow
liquorice oat cake lollipop. Lemon drops oat cake halvah liquorice danish
powder cupcake soufflé. Cake tart topping jelly-o tart sugar plum.
Chocolate bar cookie wafer tootsie roll candy cotton candy toffee pie
donut.
</p>
<p>
Ice cream lollipop marshmallow tiramisu jujubes croissant. Bear claw lemon
drops marzipan candy bonbon cupcake powder. Candy canes cheesecake bear
claw pastry cake donut jujubes. Icing tart jelly-o soufflé bonbon apple
pie. Cheesecake pie chupa chups toffee powder. Bonbon lemon drops carrot
cake pudding candy halvah cheesecake lollipop cupcake. Pudding marshmallow
fruitcake. Gummi bears bonbon chupa chups lemon drops. Wafer dessert
gummies gummi bears biscuit donut tiramisu gummi bears brownie. Tootsie
roll liquorice bonbon cookie. Sesame snaps chocolate bar cake croissant
chupa chups cheesecake gingerbread tiramisu jelly. Cheesecake ice cream
muffin lollipop gummies. Sesame snaps jelly beans sweet bear claw tart.
</p>
<p>
Sweet topping chupa chups chocolate cake jelly-o liquorice danish. Pastry
jelly beans apple pie dessert pastry lemon drops marzipan gummies. Jelly
beans macaroon bear claw cotton candy. Toffee sweet lollipop toffee oat
cake. Jelly-o oat cake fruitcake chocolate bar sweet. Lemon drops gummies
chocolate cake lollipop bear claw croissant danish icing. Chocolate bar
donut brownie chocolate cake lemon drops chocolate bar. Cake fruitcake
pudding chocolate apple pie. Brownie tiramisu chocolate macaroon lemon
drops wafer soufflé jujubes icing. Cheesecake tiramisu cake macaroon tart
lollipop donut. Gummi bears dragée pudding bear claw. Muffin cake cupcake
candy canes. Soufflé candy canes biscuit. Macaroon gummies danish.
</p>
<p>
Cupcake cupcake tart. Cotton candy danish candy canes oat cake ice cream
candy canes powder wafer. Chocolate sesame snaps oat cake dragée
cheesecake. Sesame snaps marshmallow topping liquorice cookie marshmallow.
Liquorice pudding chocolate bar. Cake powder brownie fruitcake. Carrot
cake dessert marzipan sugar plum cupcake cheesecake pastry. Apple pie
macaroon ice cream fruitcake apple pie cookie. Tootsie roll ice cream oat
cake cheesecake donut cheesecake bear claw. Sesame snaps marzipan jelly
beans chocolate tootsie roll. Chocolate bar donut dragée ice cream
biscuit. Pie candy canes muffin candy canes ice cream tiramisu.
</p>
</div>
)

View file

@ -8,12 +8,190 @@ export default () => (
</Head>
<h1>The Cat</h1>
<Byline author='Dan Zajdband' />
<amp-img src='/static/cat.jpg' width='470' height='350' layout='responsive' alt='Meow' />
<amp-img
src='/static/cat.jpg'
width='470'
height='350'
layout='responsive'
alt='Meow'
/>
<p className='caption'>Meowwwwwwww</p>
<p>Cat ipsum dolor <a href='/dog'>sit amet</a>, eat grass, throw it back up but refuse to leave cardboard box or groom yourself 4 hours - checked, have your beauty sleep 18 hours - checked, be fabulous for the rest of the day - checked!. Hide from vacuum cleaner. Chirp at birds chew foot chase the pig around the house and meoooow!. Chase ball of string climb a tree, wait for a fireman jump to fireman then scratch his face claw drapes, for meow to be let in yet attack dog, run away and pretend to be victim meow loudly just to annoy owners. Touch water with paw then recoil in horror hide when guests come over, and tuxedo cats always looking dapper so has closed eyes but still sees you or a nice warm laptop for me to sit on pee in human's bed until he cleans the litter box. Steal the warm chair right after you get up cat not kitten around yet claws in your leg eat all the power cords. Lick sellotape curl into a furry donut immediately regret falling into bathtub or you call this cat food? and fall asleep on the washing machine. Purr for no reason hack up furballs and pelt around the house and up and down stairs chasing phantoms. If it smells like fish eat as much as you wish. Unwrap toilet paper chew iPad power cord white cat sleeps on a black shirt lick the other cats. Lounge in doorway mew. Has closed eyes but still sees you sleep on keyboard, so hunt anything that moves lick sellotape but slap owner's face at 5am until human fills food dish if it smells like fish eat as much as you wish. Meow to be let in find empty spot in cupboard and sleep all day and thug cat sit by the fire burrow under covers always hungry. Swat at dog hide when guests come over purrrrrr chew on cable so mark territory, yet howl on top of tall thing or find something else more interesting. Chase mice kitten is playing with dead mouse. Sit and stare if it fits, i sits. Mark territory damn that dog , but step on your keyboard while you're gaming and then turn in a circle put butt in owner's face human give me attention meow or eat and than sleep on your face. Friends are not food jump around on couch, meow constantly until given food, or walk on car leaving trail of paw prints on hood and windshield, and spread kitty litter all over house, going to catch the red dot today going to catch the red dot today. Jump off balcony, onto stranger's head.</p>
<p>Meow to be let out damn that dog howl uncontrollably for no reason caticus cuteicus for play riveting piece on synthesizer keyboard. Meow loudly just to annoy owners the dog smells bad for eat the fat cats food, yet ignore the squirrels, you'll never catch them anyway cat snacks spread kitty litter all over house or hopped up on catnip. Spit up on light gray carpet instead of adjacent linoleum throwup on your pillow, so cat is love, cat is life yet human is washing you why halp oh the horror flee scratch hiss bite. Chase mice. Swat turds around the house hide at bottom of staircase to trip human. Meowing non stop for food howl on top of tall thing. Shake treat bag pee in human's bed until he cleans the litter box missing until dinner time. Have secret plans climb a tree, wait for a fireman jump to fireman then scratch his face bleghbleghvomit my furball really tie the room together. Chase dog then run away purr shake treat bag spit up on light gray carpet instead of adjacent linoleum but dream about hunting birds. Hiss at vacuum cleaner milk the cow lay on arms while you're using the keyboard sleep in the bathroom sink. Stare at ceiling touch water with paw then recoil in horror or refuse to leave cardboard box. Paw at your fat belly plan steps for world domination for going to catch the red dot today going to catch the red dot today slap owner's face at 5am until human fills food dish scratch at the door then walk away for intrigued by the shower, but steal the warm chair right after you get up. Fall asleep on the washing machine destroy couch as revenge scream at teh bath so love to play with owner's hair tie. Howl uncontrollably for no reason rub whiskers on bare skin act innocent. Cats making all the muffins lick butt and make a weird face meow all night having their mate disturbing sleeping humans human give me attention meow intently stare at the same spot. Sleep on dog bed, force dog to sleep on floor spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce for wake up human for food at 4am or pooping rainbow while flying in a toasted bread costume in space sleep on keyboard put toy mouse in food bowl run out of litter box at full speed . Jump off balcony, onto stranger's head lick butt and make a weird face but go into a room to decide you didn't want to be in there anyway so then cats take over the world, pee in human's bed until he cleans the litter box and if it fits, i sits caticus cuteicus. Eats owners hair then claws head lounge in doorway, and hide when guests come over chase ball of string eat owner's food play riveting piece on synthesizer keyboard. Purrr purr littel cat, little cat purr purr spit up on light gray carpet instead of adjacent linoleum kitty loves pigs yet damn that dog meow or walk on car leaving trail of paw prints on hood and windshield. Roll on the floor purring your whiskers off meow all night having their mate disturbing sleeping humans need to chase tail meow hide when guests come over. Soft kitty warm kitty little ball of furr destroy the blinds meow leave hair everywhere attack dog, run away and pretend to be victim. Going to catch the red dot today going to catch the red dot today instantly break out into full speed gallop across the house for no reason meow so hide when guests come over, yet hide at bottom of staircase to trip human toy mouse squeak roll over claws in your leg. Cat slap dog in face lick plastic bags why must they do that.</p>
<p>Jump launch to pounce upon little yarn mouse, bare fangs at toy run hide in litter box until treats are fed touch water with paw then recoil in horror then cats take over the world i could pee on this if i had the energy. Lie on your belly and purr when you are asleep toy mouse squeak roll over so stick butt in face you call this cat food? and behind the couch curl up and sleep on the freshly laundered towels yet love to play with owner's hair tie. Knock dish off table head butt cant eat out of my own dish walk on car leaving trail of paw prints on hood and windshield find something else more interesting cats go for world domination, spit up on light gray carpet instead of adjacent linoleum sit in box. Missing until dinner time put toy mouse in food bowl run out of litter box at full speed but poop in the plant pot and nap all day caticus cuteicus. Leave hair everywhere attack feet mrow bleghbleghvomit my furball really tie the room together meowwww eat grass, throw it back up. Hate dog meowzer! find something else more interesting, yet cat snacks, so scratch at the door then walk away chase mice. Chase laser scratch the box plan steps for world domination massacre a bird in the living room and then look like the cutest and most innocent animal on the planet for stare at ceiling light and who's the baby. Stare at ceiling Gate keepers of hell, for licks paws intently sniff hand. Pooping rainbow while flying in a toasted bread costume in space. Gnaw the corn cob. Lick yarn hanging out of own butt stare at ceiling lick butt and make a weird face eat and than sleep on your face. Meow all night having their mate disturbing sleeping humans attack feet, so poop on grasses stare at wall turn and meow stare at wall some more meow again continue staring yet purr. Have my breakfast spaghetti yarn. Cats secretly make all the worlds muffins throwup on your pillow plays league of legends. Lick the plastic bag scratch at the door then walk away. Unwrap toilet paper meow to be let in walk on car leaving trail of paw prints on hood and windshield yet hide from vacuum cleaner or massacre a bird in the living room and then look like the cutest and most innocent animal on the planet. Purr lick the curtain just to be annoying go into a room to decide you didn't want to be in there anyway attack feet, and spit up on light gray carpet instead of adjacent linoleum yet lick plastic bags. Spit up on light gray carpet instead of adjacent linoleum touch water with paw then recoil in horror so cat snacks. Purr. Lick sellotape please stop looking at your phone and pet me yet stick butt in face meow. Groom yourself 4 hours - checked, have your beauty sleep 18 hours - checked, be fabulous for the rest of the day - checked! tuxedo cats always looking dapper but purrrrrr. Claws in your leg i could pee on this if i had the energy. Present belly, scratch hand when stroked man running from cops stops to pet cats, goes to jail cat not kitten around but cough furball but toy mouse squeak roll over spread kitty litter all over house curl up and sleep on the freshly laundered towels. Meow all night having their mate disturbing sleeping humans fall asleep on the washing machine find something else more interesting.</p>
<p>Ignore the squirrels, you'll never catch them anyway missing until dinner time, for intrigued by the shower, so i could pee on this if i had the energy for purrrrrr for vommit food and eat it again lick butt and make a weird face. Rub whiskers on bare skin act innocent eat grass, throw it back up or lick yarn hanging out of own butt. I am the best cat is love, cat is life, or sleep nap, mew but meoooow!. Meowzer!. Friends are not food jump off balcony, onto stranger's head intrigued by the shower, and eat a plant, kill a hand, touch water with paw then recoil in horror yet flop over.</p>
<p>Step on your keyboard while you're gaming and then turn in a circle wake up human for food at 4am so shove bum in owner's face like camera lens for see owner, run in terror run outside as soon as door open. Stand in front of the computer screen sleep on keyboard destroy the blinds with tail in the air play time play time. Shove bum in owner's face like camera lens ignore the squirrels, you'll never catch them anyway but with tail in the air need to chase tail, yet kitten is playing with dead mouse and russian blue. Hopped up on catnip refuse to leave cardboard box you call this cat food? walk on car leaving trail of paw prints on hood and windshield. Chase after silly colored fish toys around the house sleep on keyboard, or scamper shove bum in owner's face like camera lens. Groom yourself 4 hours - checked, have your beauty sleep 18 hours - checked, be fabulous for the rest of the day - checked! claw drapes bleghbleghvomit my furball really tie the room together make meme, make cute face kitty loves pigs. Toy mouse squeak roll over refuse to drink water except out of someone's glass but attack feet. Sleep on keyboard. Vommit food and eat it again paw at your fat belly, rub face on everything, yet purr. Has closed eyes but still sees you kitty scratches couch bad kitty if it fits, i sits. Pushes butt to face purrrrrr or intently stare at the same spot, yet attack dog, run away and pretend to be victim yet lies down and need to chase tail. Spend all night ensuring people don't sleep sleep all day love to play with owner's hair tie. I could pee on this if i had the energy lick butt stare out the window. Make meme, make cute face. Chase after silly colored fish toys around the house. Leave fur on owners clothes poop in the plant pot. Sleep on keyboard chase the pig around the house chase imaginary bugs, yet bleghbleghvomit my furball really tie the room together yet have my breakfast spaghetti yarn so scamper. Need to chase tail meow for food, then when human fills food dish, take a few bites of food and continue meowing for pee in the shoe thinking longingly about tuna brine yet purrr purr littel cat, little cat purr purr lie on your belly and purr when you are asleep. Lounge in doorway poop on grasses for lounge in doorway for chew iPad power cord.</p>
<p>
Cat ipsum dolor <a href='/dog'>sit amet</a>, eat grass, throw it back up
but refuse to leave cardboard box or groom yourself 4 hours - checked,
have your beauty sleep 18 hours - checked, be fabulous for the rest of the
day - checked!. Hide from vacuum cleaner. Chirp at birds chew foot chase
the pig around the house and meoooow!. Chase ball of string climb a tree,
wait for a fireman jump to fireman then scratch his face claw drapes, for
meow to be let in yet attack dog, run away and pretend to be victim meow
loudly just to annoy owners. Touch water with paw then recoil in horror
hide when guests come over, and tuxedo cats always looking dapper so has
closed eyes but still sees you or a nice warm laptop for me to sit on pee
in human's bed until he cleans the litter box. Steal the warm chair right
after you get up cat not kitten around yet claws in your leg eat all the
power cords. Lick sellotape curl into a furry donut immediately regret
falling into bathtub or you call this cat food? and fall asleep on the
washing machine. Purr for no reason hack up furballs and pelt around the
house and up and down stairs chasing phantoms. If it smells like fish eat
as much as you wish. Unwrap toilet paper chew iPad power cord white cat
sleeps on a black shirt lick the other cats. Lounge in doorway mew. Has
closed eyes but still sees you sleep on keyboard, so hunt anything that
moves lick sellotape but slap owner's face at 5am until human fills food
dish if it smells like fish eat as much as you wish. Meow to be let in
find empty spot in cupboard and sleep all day and thug cat sit by the fire
burrow under covers always hungry. Swat at dog hide when guests come over
purrrrrr chew on cable so mark territory, yet howl on top of tall thing or
find something else more interesting. Chase mice kitten is playing with
dead mouse. Sit and stare if it fits, i sits. Mark territory damn that dog
, but step on your keyboard while you're gaming and then turn in a circle
put butt in owner's face human give me attention meow or eat and than
sleep on your face. Friends are not food jump around on couch, meow
constantly until given food, or walk on car leaving trail of paw prints on
hood and windshield, and spread kitty litter all over house, going to
catch the red dot today going to catch the red dot today. Jump off
balcony, onto stranger's head.
</p>
<p>
Meow to be let out damn that dog howl uncontrollably for no reason caticus
cuteicus for play riveting piece on synthesizer keyboard. Meow loudly just
to annoy owners the dog smells bad for eat the fat cats food, yet ignore
the squirrels, you'll never catch them anyway cat snacks spread kitty
litter all over house or hopped up on catnip. Spit up on light gray carpet
instead of adjacent linoleum throwup on your pillow, so cat is love, cat
is life yet human is washing you why halp oh the horror flee scratch hiss
bite. Chase mice. Swat turds around the house hide at bottom of staircase
to trip human. Meowing non stop for food howl on top of tall thing. Shake
treat bag pee in human's bed until he cleans the litter box missing until
dinner time. Have secret plans climb a tree, wait for a fireman jump to
fireman then scratch his face bleghbleghvomit my furball really tie the
room together. Chase dog then run away purr shake treat bag spit up on
light gray carpet instead of adjacent linoleum but dream about hunting
birds. Hiss at vacuum cleaner milk the cow lay on arms while you're using
the keyboard sleep in the bathroom sink. Stare at ceiling touch water with
paw then recoil in horror or refuse to leave cardboard box. Paw at your
fat belly plan steps for world domination for going to catch the red dot
today going to catch the red dot today slap owner's face at 5am until
human fills food dish scratch at the door then walk away for intrigued by
the shower, but steal the warm chair right after you get up. Fall asleep
on the washing machine destroy couch as revenge scream at teh bath so love
to play with owner's hair tie. Howl uncontrollably for no reason rub
whiskers on bare skin act innocent. Cats making all the muffins lick butt
and make a weird face meow all night having their mate disturbing sleeping
humans human give me attention meow intently stare at the same spot. Sleep
on dog bed, force dog to sleep on floor spot something, big eyes, big
eyes, crouch, shake butt, prepare to pounce for wake up human for food at
4am or pooping rainbow while flying in a toasted bread costume in space
sleep on keyboard put toy mouse in food bowl run out of litter box at full
speed . Jump off balcony, onto stranger's head lick butt and make a weird
face but go into a room to decide you didn't want to be in there anyway so
then cats take over the world, pee in human's bed until he cleans the
litter box and if it fits, i sits caticus cuteicus. Eats owners hair then
claws head lounge in doorway, and hide when guests come over chase ball of
string eat owner's food play riveting piece on synthesizer keyboard. Purrr
purr littel cat, little cat purr purr spit up on light gray carpet instead
of adjacent linoleum kitty loves pigs yet damn that dog meow or walk on
car leaving trail of paw prints on hood and windshield. Roll on the floor
purring your whiskers off meow all night having their mate disturbing
sleeping humans need to chase tail meow hide when guests come over. Soft
kitty warm kitty little ball of furr destroy the blinds meow leave hair
everywhere attack dog, run away and pretend to be victim. Going to catch
the red dot today going to catch the red dot today instantly break out
into full speed gallop across the house for no reason meow so hide when
guests come over, yet hide at bottom of staircase to trip human toy mouse
squeak roll over claws in your leg. Cat slap dog in face lick plastic bags
why must they do that.
</p>
<p>
Jump launch to pounce upon little yarn mouse, bare fangs at toy run hide
in litter box until treats are fed touch water with paw then recoil in
horror then cats take over the world i could pee on this if i had the
energy. Lie on your belly and purr when you are asleep toy mouse squeak
roll over so stick butt in face you call this cat food? and behind the
couch curl up and sleep on the freshly laundered towels yet love to play
with owner's hair tie. Knock dish off table head butt cant eat out of my
own dish walk on car leaving trail of paw prints on hood and windshield
find something else more interesting cats go for world domination, spit up
on light gray carpet instead of adjacent linoleum sit in box. Missing
until dinner time put toy mouse in food bowl run out of litter box at full
speed but poop in the plant pot and nap all day caticus cuteicus. Leave
hair everywhere attack feet mrow bleghbleghvomit my furball really tie the
room together meowwww eat grass, throw it back up. Hate dog meowzer! find
something else more interesting, yet cat snacks, so scratch at the door
then walk away chase mice. Chase laser scratch the box plan steps for
world domination massacre a bird in the living room and then look like the
cutest and most innocent animal on the planet for stare at ceiling light
and who's the baby. Stare at ceiling Gate keepers of hell, for licks paws
intently sniff hand. Pooping rainbow while flying in a toasted bread
costume in space. Gnaw the corn cob. Lick yarn hanging out of own butt
stare at ceiling lick butt and make a weird face eat and than sleep on
your face. Meow all night having their mate disturbing sleeping humans
attack feet, so poop on grasses stare at wall turn and meow stare at wall
some more meow again continue staring yet purr. Have my breakfast
spaghetti yarn. Cats secretly make all the worlds muffins throwup on your
pillow plays league of legends. Lick the plastic bag scratch at the door
then walk away. Unwrap toilet paper meow to be let in walk on car leaving
trail of paw prints on hood and windshield yet hide from vacuum cleaner or
massacre a bird in the living room and then look like the cutest and most
innocent animal on the planet. Purr lick the curtain just to be annoying
go into a room to decide you didn't want to be in there anyway attack
feet, and spit up on light gray carpet instead of adjacent linoleum yet
lick plastic bags. Spit up on light gray carpet instead of adjacent
linoleum touch water with paw then recoil in horror so cat snacks. Purr.
Lick sellotape please stop looking at your phone and pet me yet stick butt
in face meow. Groom yourself 4 hours - checked, have your beauty sleep 18
hours - checked, be fabulous for the rest of the day - checked! tuxedo
cats always looking dapper but purrrrrr. Claws in your leg i could pee on
this if i had the energy. Present belly, scratch hand when stroked man
running from cops stops to pet cats, goes to jail cat not kitten around
but cough furball but toy mouse squeak roll over spread kitty litter all
over house curl up and sleep on the freshly laundered towels. Meow all
night having their mate disturbing sleeping humans fall asleep on the
washing machine find something else more interesting.
</p>
<p>
Ignore the squirrels, you'll never catch them anyway missing until dinner
time, for intrigued by the shower, so i could pee on this if i had the
energy for purrrrrr for vommit food and eat it again lick butt and make a
weird face. Rub whiskers on bare skin act innocent eat grass, throw it
back up or lick yarn hanging out of own butt. I am the best cat is love,
cat is life, or sleep nap, mew but meoooow!. Meowzer!. Friends are not
food jump off balcony, onto stranger's head intrigued by the shower, and
eat a plant, kill a hand, touch water with paw then recoil in horror yet
flop over.
</p>
<p>
Step on your keyboard while you're gaming and then turn in a circle wake
up human for food at 4am so shove bum in owner's face like camera lens for
see owner, run in terror run outside as soon as door open. Stand in front
of the computer screen sleep on keyboard destroy the blinds with tail in
the air play time play time. Shove bum in owner's face like camera lens
ignore the squirrels, you'll never catch them anyway but with tail in the
air need to chase tail, yet kitten is playing with dead mouse and russian
blue. Hopped up on catnip refuse to leave cardboard box you call this cat
food? walk on car leaving trail of paw prints on hood and windshield.
Chase after silly colored fish toys around the house sleep on keyboard, or
scamper shove bum in owner's face like camera lens. Groom yourself 4 hours
- checked, have your beauty sleep 18 hours - checked, be fabulous for the
rest of the day - checked! claw drapes bleghbleghvomit my furball really
tie the room together make meme, make cute face kitty loves pigs. Toy
mouse squeak roll over refuse to drink water except out of someone's glass
but attack feet. Sleep on keyboard. Vommit food and eat it again paw at
your fat belly, rub face on everything, yet purr. Has closed eyes but
still sees you kitty scratches couch bad kitty if it fits, i sits. Pushes
butt to face purrrrrr or intently stare at the same spot, yet attack dog,
run away and pretend to be victim yet lies down and need to chase tail.
Spend all night ensuring people don't sleep sleep all day love to play
with owner's hair tie. I could pee on this if i had the energy lick butt
stare out the window. Make meme, make cute face. Chase after silly colored
fish toys around the house. Leave fur on owners clothes poop in the plant
pot. Sleep on keyboard chase the pig around the house chase imaginary
bugs, yet bleghbleghvomit my furball really tie the room together yet have
my breakfast spaghetti yarn so scamper. Need to chase tail meow for food,
then when human fills food dish, take a few bites of food and continue
meowing for pee in the shoe thinking longingly about tuna brine yet purrr
purr littel cat, little cat purr purr lie on your belly and purr when you
are asleep. Lounge in doorway poop on grasses for lounge in doorway for
chew iPad power cord.
</p>
</div>
)

View file

@ -6,21 +6,17 @@ const path = require('path')
// Where your antd-custom.less file lives
const themeVariables = lessToJS(
fs.readFileSync(
path.resolve(__dirname, './assets/antd-custom.less'),
'utf8'
)
fs.readFileSync(path.resolve(__dirname, './assets/antd-custom.less'), 'utf8')
)
// fix: prevents error when .less files are required by node
if (typeof require !== 'undefined') {
require.extensions['.less'] = (file) => {}
require.extensions['.less'] = file => {}
}
module.exports = withLess({
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: themeVariables // make your antd custom effective
},
}
})

View file

@ -1,4 +1,12 @@
import { Form, Select, InputNumber, DatePicker, Switch, Slider, Button } from 'antd'
import {
Form,
Select,
InputNumber,
DatePicker,
Switch,
Slider,
Button
} from 'antd'
const FormItem = Form.Item
const Option = Select.Option
@ -11,35 +19,37 @@ export default () => (
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<InputNumber size='large' min={1} max={10} style={{ width: 100 }} defaultValue={3} name='inputNumber' />
<InputNumber
size='large'
min={1}
max={10}
style={{ width: 100 }}
defaultValue={3}
name='inputNumber'
/>
<a href='#'>Link</a>
</FormItem>
<FormItem
label='Switch'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<FormItem label='Switch' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Switch defaultChecked name='switch' />
</FormItem>
<FormItem
label='Slider'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<FormItem label='Slider' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Slider defaultValue={70} />
</FormItem>
<FormItem
label='Select'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Select size='large' defaultValue='lucy' style={{ width: 192 }} name='select'>
<FormItem label='Select' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Select
size='large'
defaultValue='lucy'
style={{ width: 192 }}
name='select'
>
<Option value='jack'>jack</Option>
<Option value='lucy'>lucy</Option>
<Option value='disabled' disabled>disabled</Option>
<Option value='disabled' disabled>
disabled
</Option>
<Option value='yiminghe'>yiminghe</Option>
</Select>
</FormItem>
@ -51,15 +61,12 @@ export default () => (
>
<DatePicker name='startDate' />
</FormItem>
<FormItem
style={{ marginTop: 48 }}
wrapperCol={{ span: 8, offset: 8 }}
>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}>
<Button size='large' type='primary' htmlType='submit'>
OK
OK
</Button>
<Button size='large' style={{ marginLeft: 8 }}>
Cancel
Cancel
</Button>
</FormItem>
</Form>

View file

@ -3,7 +3,7 @@ const withCss = require('@zeit/next-css')
// fix: prevents error when .css files are required by node
if (typeof require !== 'undefined') {
require.extensions['.css'] = (file) => {}
require.extensions['.css'] = file => {}
}
module.exports = withCss()

View file

@ -1,4 +1,12 @@
import { Form, Select, InputNumber, DatePicker, Switch, Slider, Button } from 'antd'
import {
Form,
Select,
InputNumber,
DatePicker,
Switch,
Slider,
Button
} from 'antd'
const FormItem = Form.Item
const Option = Select.Option
@ -11,35 +19,37 @@ export default () => (
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<InputNumber size='large' min={1} max={10} style={{ width: 100 }} defaultValue={3} name='inputNumber' />
<InputNumber
size='large'
min={1}
max={10}
style={{ width: 100 }}
defaultValue={3}
name='inputNumber'
/>
<a href='#'>Link</a>
</FormItem>
<FormItem
label='Switch'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<FormItem label='Switch' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Switch defaultChecked name='switch' />
</FormItem>
<FormItem
label='Slider'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<FormItem label='Slider' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Slider defaultValue={70} />
</FormItem>
<FormItem
label='Select'
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<Select size='large' defaultValue='lucy' style={{ width: 192 }} name='select'>
<FormItem label='Select' labelCol={{ span: 8 }} wrapperCol={{ span: 8 }}>
<Select
size='large'
defaultValue='lucy'
style={{ width: 192 }}
name='select'
>
<Option value='jack'>jack</Option>
<Option value='lucy'>lucy</Option>
<Option value='disabled' disabled>disabled</Option>
<Option value='disabled' disabled>
disabled
</Option>
<Option value='yiminghe'>yiminghe</Option>
</Select>
</FormItem>
@ -51,15 +61,12 @@ export default () => (
>
<DatePicker name='startDate' />
</FormItem>
<FormItem
style={{ marginTop: 48 }}
wrapperCol={{ span: 8, offset: 8 }}
>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ span: 8, offset: 8 }}>
<Button size='large' type='primary' htmlType='submit'>
OK
OK
</Button>
<Button size='large' style={{ marginLeft: 8 }}>
Cancel
Cancel
</Button>
</FormItem>
</Form>

View file

@ -26,8 +26,6 @@ export default withRouter(({ router, children, title }) => (
position: relative;
}
`}</style>
<WingBlank>
{children}
</WingBlank>
<WingBlank>{children}</WingBlank>
</div>
))

Some files were not shown because too many files have changed in this diff Show more