Skip to content

Commit 9986cd4

Browse files
committed
add basic route
1 parent 374726d commit 9986cd4

File tree

7 files changed

+317
-12
lines changed

7 files changed

+317
-12
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.next/
3+
*.log
4+
*.swp
5+
*.swo

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
"name": "nextjs-real-world",
1111
"version": "1.0.0",
1212
"main": "server/index.js",
13-
"devDependencies": {},
13+
"devDependencies": {
14+
"nodemon": "^1.12.1"
15+
},
1416
"scripts": {
15-
"test": "echo \"Error: no test specified\" && exit 1"
17+
"test": "echo \"Error: no test specified\" && exit 1",
18+
"build": "next build",
19+
"start": "nodemon -w server server/index.js"
1620
},
1721
"author": "Ian Wang <[email protected]> (https://github.com/IanWang)",
1822
"license": "ISC",

pages/about.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default props => <h1>About</h1>

pages/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { Link } from '../routes'
12

23
export default () => (
34
<div className='hello'>
45
next.js real world
6+
<div>
7+
<Link route='/about'>About</Link>
8+
</div>
59
<style jsx>{`
6-
.hello-lite {
10+
.hello {
711
font: 20px Helvetica, Arial, sans-serif;
812
background: #f8f8f8;
913
color: #b0b0b0;

routes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
const nextRoutes = require('next-routes')
22
const routes = module.exports = nextRoutes()
3+
4+
routes.add('about', '/about')

server/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const routes = require('../routes')
99
const port = parseInt(process.env.PORT, 10) || 3100
1010
const dev = process.env.NODE_ENV !== 'production'
1111
const app = next({ dev })
12-
const handler = routes.getRequestHandler()
12+
13+
const handler = routes.getRequestHandler(app)
1314

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

0 commit comments

Comments
 (0)