Skip to content

Commit

Permalink
add basic route
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwang committed Oct 22, 2017
1 parent 374726d commit 9986cd4
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.next/
*.log
*.swp
*.swo
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
"name": "nextjs-real-world",
"version": "1.0.0",
"main": "server/index.js",
"devDependencies": {},
"devDependencies": {
"nodemon": "^1.12.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "next build",
"start": "nodemon -w server server/index.js"
},
"author": "Ian Wang <[email protected]> (https://github.com/IanWang)",
"license": "ISC",
Expand Down
1 change: 1 addition & 0 deletions pages/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default props => <h1>About</h1>
6 changes: 5 additions & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Link } from '../routes'

export default () => (
<div className='hello'>
next.js real world
<div>
<Link route='/about'>About</Link>
</div>
<style jsx>{`
.hello-lite {
.hello {
font: 20px Helvetica, Arial, sans-serif;
background: #f8f8f8;
color: #b0b0b0;
Expand Down
2 changes: 2 additions & 0 deletions routes.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
const nextRoutes = require('next-routes')
const routes = module.exports = nextRoutes()

routes.add('about', '/about')
3 changes: 2 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const routes = require('../routes')
const port = parseInt(process.env.PORT, 10) || 3100
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handler = routes.getRequestHandler()

const handler = routes.getRequestHandler(app)

app.prepare().then(() => {

Expand Down
Loading

0 comments on commit 9986cd4

Please sign in to comment.